class method
URI.parse
(::_ToStr uri) -> (::URI::File | ::URI::FTP | ::URI::HTTP | ::URI::HTTPS | ::URI::LDAP | ::URI::LDAPS | ::URI::MailTo | ::URI::WS | ::URI::WSS | ::URI::Generic)
parse(uri)
lib/uri/common.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/uri/common.rb, line 246
def self.parse(uri)
PARSER.parse(uri)
end
Returns a new URI object constructed from the given string uri:
Example
URI.parse('https://[email protected]:123/forum/questions/?tag=networking&order=newest#top') # => #<URI::HTTPS https://[email protected]:123/forum/questions/?tag=networking&order=newest#top> URI.parse('http://[email protected]:123/forum/questions/?tag=networking&order=newest#top') # => #<URI::HTTP http://[email protected]:123/forum/questions/?tag=networking&order=newest#top>
It’s recommended to first URI::RFC2396_PARSER.escape string uri if it may contain invalid URI characters.