Skip to content

Commit

Permalink
eth/ens: restore docs for normalize (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
q9f authored Jan 2, 2023
1 parent d41b865 commit 94a168b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/eth/ens/resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,16 @@ def namehash(ens_name)
Util.bin_to_prefixed_hex node
end

def normalize(ens_name)
name = ens_name.dup
# Normalize a string as specified by http://unicode.org/reports/tr46/
#
# @param input [String] The input string
# @return [String] The normalized output string
def normalize(input)
name = input.dup
if name.gsub!(/[`~!@#$%^&*()_=+\[\]{}<>,;:'"\/\\|?]/, "").nil?
return ens_name.downcase
return input.downcase
else
raise ArgumentError, "Provided ENS name contains illegal characters: #{ens_name}"
raise ArgumentError, "Provided ENS name contains illegal characters: #{input}"
end
end
end
Expand Down

0 comments on commit 94a168b

Please sign in to comment.