Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

class method

URI.split

split(uri)

Synopsis

Example
URI::split(uri)

Args

uri

String with URI.

Description

Splits the string on following parts and returns array with result:

  • Scheme

  • Userinfo

  • Host

  • Port

  • Registry

  • Path

  • Opaque

  • Query

  • Fragment

Usage

Example
require 'uri'

URI.split("http://www.ruby-lang.org/")
# => ["http", nil, "www.ruby-lang.org", nil, nil, "/", nil, nil, nil]
See also .scheme_list .register_scheme also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0