File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3333 os :
3434 - ubuntu-latest
3535 ruby :
36+ - " 2.5"
37+ - " 2.6"
3638 - " 2.7"
3739 - " 3.0"
3840 - " 3.1"
Original file line number Diff line number Diff line change 11AllCops :
2- TargetRubyVersion : 2.7
2+ TargetRubyVersion : 2.5
33 NewCops : enable
44 SuggestExtensions : false
55 Exclude :
Original file line number Diff line number Diff line change @@ -28,12 +28,26 @@ def generate(data)
2828 # JWT::JSON.parse('{"a":1,"a":2}', allow_duplicate_keys: false)
2929 # # => raises JWT::DuplicateKeyError
3030 def parse ( data , allow_duplicate_keys : true )
31- ::JSON . parse ( data , allow_duplicate_key : allow_duplicate_keys )
31+ return ::JSON . parse ( data ) if allow_duplicate_keys
32+
33+ if supports_duplicate_key_detection?
34+ ::JSON . parse ( data , allow_duplicate_key : false )
35+ else
36+ ::JSON . parse ( data )
37+ end
3238 rescue ::JSON ::ParserError => e
3339 raise JWT ::DuplicateKeyError , e . message if e . message . include? ( 'duplicate key' )
3440
3541 raise
3642 end
43+
44+ private
45+
46+ def supports_duplicate_key_detection?
47+ return @supports_duplicate_key_detection if defined? ( @supports_duplicate_key_detection )
48+
49+ @supports_duplicate_key_detection = Gem ::Version . new ( ::JSON ::VERSION ) >= Gem ::Version . new ( '2.13.0' )
50+ end
3751 end
3852 end
3953end
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
1515 spec . description = 'A pure ruby implementation of the RFC 7519 OAuth JSON Web Token (JWT) standard.'
1616 spec . homepage = 'https://github.com/jwt/ruby-jwt'
1717 spec . license = 'MIT'
18- spec . required_ruby_version = '>= 2.7 '
18+ spec . required_ruby_version = '>= 2.5 '
1919 spec . metadata = {
2020 'bug_tracker_uri' => 'https://github.com/jwt/ruby-jwt/issues' ,
2121 'changelog_uri' => "https://github.com/jwt/ruby-jwt/blob/v#{ JWT . gem_version } /CHANGELOG.md" ,
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
3232 spec . require_paths = %w[ lib ]
3333
3434 spec . add_dependency 'base64'
35- spec . add_dependency 'json' , '>= 2.13.0'
35+ spec . add_dependency 'json'
3636
3737 spec . add_development_dependency 'appraisal'
3838 spec . add_development_dependency 'bundler'
You can’t perform that action at this time.
0 commit comments