class Bundler::URI::Generic

def hostname


uri.host #=> "[::1]"
uri.hostname #=> "::1"
uri = Bundler::URI("http://[::1]/bar")

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

Extract the host part of the Bundler::URI and unwrap brackets for IPv6 addresses.
def hostname
  v = self.host
  v&.start_with?('[') && v.end_with?(']') ? v[1..-2] : v
end