diff --git a/lib/uri/common.rb b/lib/uri/common.rb index 17bea9e97a..ac72a9ebc2 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -185,23 +185,13 @@ module URI RFC3986_PARSER.parse(uri) end + # Merges the given URI strings +str+ + # per {RFC 2396}[https://www.rfc-editor.org/rfc/rfc2396.html]. # - # == Synopsis + # Each string in +str+ is converted to an + # {RFC3986 URI}[https://www.rfc-editor.org/rfc/rfc3986.html] before being merged. # - # URI::join(str[, str, ...]) - # - # == Args - # - # +str+:: - # String(s) to work with, will be converted to RFC3986 URIs before merging. - # - # == Description - # - # Joins URIs. - # - # == Usage - # - # require 'uri' + # Examples: # # URI.join("http://example.com/","main.rbx") # # => # @@ -246,7 +236,7 @@ module URI # URI.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.") # # => ["http://foo.example.com/bla", "mailto:test@example.com"] # - def self.extract(str, schemes = nil, &block) + def self.extract(str, schemes = nil, &block) # :nodoc: warn "URI.extract is obsolete", uplevel: 1 if $VERBOSE DEFAULT_PARSER.extract(str, schemes, &block) end @@ -283,7 +273,7 @@ module URI # p $& # end # - def self.regexp(schemes = nil) + def self.regexp(schemes = nil)# :nodoc: warn "URI.regexp is obsolete", uplevel: 1 if $VERBOSE DEFAULT_PARSER.make_regexp(schemes) end @@ -340,16 +330,38 @@ module URI # and then to encoding +enc+. # # In either case, the returned string has forced encoding Encoding::US_ASCII. - # def self.encode_www_form_component(str, enc=nil) _encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCWWWCOMP_, str, enc) end - # Decodes given +str+ of URL-encoded form data. + # Returns a string decoded from the given \URL-encoded string +str+. # - # This decodes + to SP. + # The given string is first encoded as Encoding::ASCII-8BIT (using String#b), + # then decoded (as below), and finally force-encoded to the given encoding +enc+. + # + # The returned string: + # + # - Preserves: + # + # - Characters '*', '.', '-', and '_'. + # - Character in ranges 'a'..'z', 'A'..'Z', + # and '0'..'9'. + # + # Example: + # + # URI.decode_www_form_component('*.-_azAZ09') + # # => "*.-_azAZ09" + # + # - Converts: + # + # - Character '+' to character ' '. + # - Each "percent notation" to an ASCII character. + # + # Example: + # + # URI.decode_www_form_component('Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A') + # # => "Here are some punctuation characters: ,;?:" # - # See URI.encode_www_form_component, URI.decode_www_form. def self.decode_www_form_component(str, enc=Encoding::UTF_8) _decode_uri_component(/\+|%\h\h/, str, enc) end