lib/httpx/domain_name.rb in httpx-1.0.2 vs lib/httpx/domain_name.rb in httpx-1.1.0
- old
+ new
@@ -59,11 +59,15 @@
end
# Normalizes a _domain_ using the Punycode algorithm as necessary.
# The result will be a downcased, ASCII-only string.
def normalize(domain)
- domain = domain.chomp(".").unicode_normalize(:nfc) unless domain.ascii_only?
- Punycode.encode_hostname(domain).downcase
+ unless domain.ascii_only?
+ domain = domain.chomp(".").unicode_normalize(:nfc)
+ domain = Punycode.encode_hostname(domain)
+ end
+
+ domain.downcase
end
end
# Parses _hostname_ into a DomainName object. An IP address is also
# accepted. An IPv6 address may be enclosed in square brackets.