Skip to content

Commit

Permalink
Upgrade uri-idna
Browse files Browse the repository at this point in the history
  • Loading branch information
skryukov committed Nov 22, 2023
1 parent 12f29a6 commit 995e5ef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion json_skooma.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency "zeitwerk", "~> 2.6"
spec.add_runtime_dependency "hana", "~> 1.3"
spec.add_runtime_dependency "regexp_parser", "~> 2.0"
spec.add_runtime_dependency "uri-idna", "~> 0.1"
spec.add_runtime_dependency "uri-idna", "~> 0.2"
end
3 changes: 2 additions & 1 deletion lib/json_skooma/validators/idn_hostname.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ module JSONSkooma
module Validators
class IdnHostname < Base
def call(data)
URI::IDNA.register(ulabel: data.value)
register_opts = data.value.ascii_only? ? {alabel: data.value} : {ulabel: data.value}
URI::IDNA.register(**register_opts)
rescue URI::IDNA::Error => e
raise FormatError, "#{data} is not a valid IDN hostname: #{e.message}"
end
Expand Down

0 comments on commit 995e5ef

Please sign in to comment.