Method: Addressable::URI#normalized_host

Defined in:
lib/vendor/addressable/lib/addressable/uri.rb

#normalized_hostString

The host component for this URI, normalized.

Returns:

  • (String)

    The host component, normalized.



866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
# File 'lib/vendor/addressable/lib/addressable/uri.rb', line 866

def normalized_host
  @normalized_host ||= (begin
    if self.host != nil
      if self.host.strip != ""
        result = ::Addressable::IDNA.to_ascii(
          self.class.unencode_component(self.host.strip.downcase)
        )
        if result[-1..-1] == "."
          # Trailing dots are unnecessary
          result = result[0...-1]
        end
        result
      else
        ""
      end
    else
      nil
    end
  end)
end