Class: URI::Generic

Inherits:
Object
  • Object
show all
Defined in:
lib/excon/extensions/uri.rb

Instance Method Summary collapse

Instance Method Details

#hostnameObject

extract the host part of the URI and unwrap brackets for IPv6 addresses.

This method is same as URI::Generic#host except brackets for IPv6 (and future IP) addresses are removed.

u = URI(“http://[::1]/bar”) p u.hostname #=> “::1” p u.host #=> “[::1]”



28
29
30
31
# File 'lib/excon/extensions/uri.rb', line 28

def hostname
  v = self.host
  /\A\[(.*)\]\z/ =~ v ? $1 : v
end