[ruby/uri] [DOC] Common rdoc (https://github.com/ruby/uri/pull/52)
https://github.com/ruby/uri/commit/be8047028f
This commit is contained in:
parent
28cfc0c116
commit
fd98169e00
@ -330,6 +330,8 @@ module URI
|
|||||||
# and then to encoding +enc+.
|
# and then to encoding +enc+.
|
||||||
#
|
#
|
||||||
# In either case, the returned string has forced encoding Encoding::US_ASCII.
|
# In either case, the returned string has forced encoding Encoding::US_ASCII.
|
||||||
|
#
|
||||||
|
# Related: URI.encode_uri_component (encodes <tt>' '</tt> as <tt>'%20'</tt>).
|
||||||
def self.encode_www_form_component(str, enc=nil)
|
def self.encode_www_form_component(str, enc=nil)
|
||||||
_encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCWWWCOMP_, str, enc)
|
_encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCWWWCOMP_, str, enc)
|
||||||
end
|
end
|
||||||
@ -362,20 +364,18 @@ module URI
|
|||||||
# URI.decode_www_form_component('Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A')
|
# URI.decode_www_form_component('Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A')
|
||||||
# # => "Here are some punctuation characters: ,;?:"
|
# # => "Here are some punctuation characters: ,;?:"
|
||||||
#
|
#
|
||||||
|
# Related: URI.decode_uri_component (preserves <tt>'+'</tt>).
|
||||||
def self.decode_www_form_component(str, enc=Encoding::UTF_8)
|
def self.decode_www_form_component(str, enc=Encoding::UTF_8)
|
||||||
_decode_uri_component(/\+|%\h\h/, str, enc)
|
_decode_uri_component(/\+|%\h\h/, str, enc)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Encodes +str+ using URL encoding
|
# Like URI.encode_www_form_component, except that <tt>' '</tt> (space)
|
||||||
#
|
# is encoded as <tt>'%20'</tt> (instead of <tt>'+'</tt>).
|
||||||
# This encodes SP to %20 instead of +.
|
|
||||||
def self.encode_uri_component(str, enc=nil)
|
def self.encode_uri_component(str, enc=nil)
|
||||||
_encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCURICOMP_, str, enc)
|
_encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCURICOMP_, str, enc)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Decodes given +str+ of URL-encoded data.
|
# Like URI.decode_www_form_component, except that <tt>'+'</tt> is preserved.
|
||||||
#
|
|
||||||
# This does not decode + to SP.
|
|
||||||
def self.decode_uri_component(str, enc=Encoding::UTF_8)
|
def self.decode_uri_component(str, enc=Encoding::UTF_8)
|
||||||
_decode_uri_component(/%\h\h/, str, enc)
|
_decode_uri_component(/%\h\h/, str, enc)
|
||||||
end
|
end
|
||||||
@ -419,6 +419,12 @@ module URI
|
|||||||
# URI.encode_www_form({foo: 0, bar: 1, baz: 2})
|
# URI.encode_www_form({foo: 0, bar: 1, baz: 2})
|
||||||
# # => "foo=0&bar=1&baz=2"
|
# # => "foo=0&bar=1&baz=2"
|
||||||
#
|
#
|
||||||
|
# The returned string is formed using method URI.encode_www_form_component,
|
||||||
|
# which converts certain characters:
|
||||||
|
#
|
||||||
|
# URI.encode_www_form('f#o': '/', 'b-r': '$')
|
||||||
|
# # => "f%23o=%2F&b-r=%24"
|
||||||
|
#
|
||||||
# When +enum+ is Array-like, each element +ele+ is converted to a field:
|
# When +enum+ is Array-like, each element +ele+ is converted to a field:
|
||||||
#
|
#
|
||||||
# - If +ele+ is an array of two or more elements,
|
# - If +ele+ is an array of two or more elements,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user