method

hostname=

v2_2_9 - Show latest stable - Class: URI::Generic
hostname=(v)
public

set the host part of the URI as the argument with brackets for IPv6 addresses.

This method is same as URI::Generic#host= except the argument can be bare IPv6 address.

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

If the argument seems IPv6 address, it is wrapped by brackets.