From 94a168b9b876e5c988edf29489101774ae88096d Mon Sep 17 00:00:00 2001 From: Afri <58883403+q9f@users.noreply.github.com> Date: Mon, 2 Jan 2023 17:45:40 +0100 Subject: [PATCH] eth/ens: restore docs for normalize (#198) --- lib/eth/ens/resolver.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/eth/ens/resolver.rb b/lib/eth/ens/resolver.rb index 2a64435e..1b57bace 100644 --- a/lib/eth/ens/resolver.rb +++ b/lib/eth/ens/resolver.rb @@ -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