Method: URI.parse
- Defined in:
- lib/uri/common.rb
.parse(uri) ⇒ Object
Synopsis
URI::parse(uri_str)
Args
uri_str-
String with URI.
Description
Creates one of the URI’s subclasses instance from the string.
Raises
- URI::InvalidURIError
-
Raised if URI given is not a correct one.
Usage
require 'uri'
uri = URI.parse("http://www.ruby-lang.org/")
# => #<URI::HTTP http://www.ruby-lang.org/>
uri.scheme
# => "http"
uri.host
# => "www.ruby-lang.org"
It’s recommended to first ::escape the provided uri_str if there are any invalid URI characters.
170 171 172 |
# File 'lib/uri/common.rb', line 170 def self.parse(uri) RFC3986_PARSER.parse(uri) end |