summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBurdette Lamar <BurdetteLamar@Yahoo.com>2023-01-06 08:20:31 -0600
committergit <svn-admin@ruby-lang.org>2023-01-06 14:20:38 +0000
commitddbf7be94d8653f1b2b0325d3e65bc88e50623ec (patch)
tree37acb39f30827f926a2371acb90e70be9daa7337 /lib
parentcee5beab1d7bf6f99530957494ab9775696d42ce (diff)
[ruby/uri] [DOC] Enhanced RDoc for common methods
(https://github.com/ruby/uri/pull/50) https://github.com/ruby/uri/commit/7ff4fb372b
Diffstat (limited to 'lib')
-rw-r--r--lib/uri/common.rb54
1 files changed, 33 insertions, 21 deletions
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
- #
- # URI::join(str[, str, ...])
- #
- # == Args
- #
- # +str+::
- # String(s) to work with, will be converted to RFC3986 URIs before merging.
- #
- # == Description
+ # Each string in +str+ is converted to an
+ # {RFC3986 URI}[https://www.rfc-editor.org/rfc/rfc3986.html] before being merged.
#
- # Joins URIs.
- #
- # == Usage
- #
- # require 'uri'
+ # Examples:
#
# URI.join("http://example.com/","main.rbx")
# # => #<URI::HTTP 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+.
+ #
+ # 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 <tt>'*'</tt>, <tt>'.'</tt>, <tt>'-'</tt>, and <tt>'_'</tt>.
+ # - Character in ranges <tt>'a'..'z'</tt>, <tt>'A'..'Z'</tt>,
+ # and <tt>'0'..'9'</tt>.
+ #
+ # Example:
+ #
+ # URI.decode_www_form_component('*.-_azAZ09')
+ # # => "*.-_azAZ09"
+ #
+ # - Converts:
+ #
+ # - Character <tt>'+'</tt> to character <tt>' '</tt>.
+ # - Each "percent notation" to an ASCII character.
+ #
+ # Example:
#
- # This decodes + to SP.
+ # 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