Skip to content
class method

URI.split

(::_ToStr uri) -> [ ::String?, ::String?, ::String?, ::String?, nil, ::String?, ::String?, ::String?, ::String? ]
split(uri)

Returns a 9-element array representing the parts of the URI formed from the string uri; each array element is a string or nil:

Example
names = %w[scheme userinfo host port registry path opaque query fragment]
values = URI.split('https://[email protected]:123/forum/questions/?tag=networking&order=newest#top')
names.zip(values)
# =>
[["scheme", "https"],
 ["userinfo", "john.doe"],
 ["host", "www.example.com"],
 ["port", "123"],
 ["registry", nil],
 ["path", "/forum/questions/"],
 ["opaque", nil],
 ["query", "tag=networking&order=newest"],
 ["fragment", "top"]]
See also .scheme_list .register_scheme also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0