class Addressable::URI
def normalized_host
-
(String)
- The host component, normalized.
def normalized_host return nil unless self.host @normalized_host ||= begin if !self.host.strip.empty? result = ::Addressable::IDNA.to_ascii( URI.unencode_component(self.host.strip.downcase) ) if result =~ /[^\.]\.$/ # Single trailing dots are unnecessary. result = result[0...-1] end result = Addressable::URI.normalize_component( result, CharacterClasses::HOST) result else EMPTY_STR.dup end end # All normalized values should be UTF-8 @normalized_host.force_encoding(Encoding::UTF_8) if @normalized_host @normalized_host end