Method: Addressable::URI#to_s
- Defined in:
- lib/addressable/uri.rb
#to_s ⇒ String Also known as: to_str
Converts the URI to a String
.
2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 |
# File 'lib/addressable/uri.rb', line 2341 def to_s if self.scheme == nil && self.path != nil && !self.path.empty? && self.path =~ NORMPATH raise InvalidURIError, "Cannot assemble URI string with ambiguous path: '#{self.path}'" end @uri_string ||= begin uri_string = String.new uri_string << "#{self.scheme}:" if self.scheme != nil uri_string << "//#{self.authority}" if self. != nil uri_string << self.path.to_s uri_string << "?#{self.query}" if self.query != nil uri_string << "##{self.fragment}" if self.fragment != nil uri_string.force_encoding(Encoding::UTF_8) uri_string end end |