@@ -185,23 +185,13 @@ def self.parse(uri)
185
185
RFC3986_PARSER . parse ( uri )
186
186
end
187
187
188
+ # Merges the given URI strings +str+
189
+ # per {RFC 2396}[https://www.rfc-editor.org/rfc/rfc2396.html].
188
190
#
189
- # == Synopsis
190
- #
191
- # URI::join(str[, str, ...])
192
- #
193
- # == Args
194
- #
195
- # +str+::
196
- # String(s) to work with, will be converted to RFC3986 URIs before merging.
197
- #
198
- # == Description
191
+ # Each string in +str+ is converted to an
192
+ # {RFC3986 URI}[https://www.rfc-editor.org/rfc/rfc3986.html] before being merged.
199
193
#
200
- # Joins URIs.
201
- #
202
- # == Usage
203
- #
204
- # require 'uri'
194
+ # Examples:
205
195
#
206
196
# URI.join("http://example.com/","main.rbx")
207
197
# # => #<URI::HTTP http://example.com/main.rbx>
@@ -246,7 +236,7 @@ def self.join(*str)
246
236
# URI.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.")
247
237
# # => ["http://foo.example.com/bla", "mailto:test@example.com"]
248
238
#
249
- def self . extract ( str , schemes = nil , &block )
239
+ def self . extract ( str , schemes = nil , &block ) # :nodoc:
250
240
warn "URI.extract is obsolete" , uplevel : 1 if $VERBOSE
251
241
DEFAULT_PARSER . extract ( str , schemes , &block )
252
242
end
@@ -283,7 +273,7 @@ def self.extract(str, schemes = nil, &block)
283
273
# p $&
284
274
# end
285
275
#
286
- def self . regexp ( schemes = nil )
276
+ def self . regexp ( schemes = nil ) # :nodoc:
287
277
warn "URI.regexp is obsolete" , uplevel : 1 if $VERBOSE
288
278
DEFAULT_PARSER . make_regexp ( schemes )
289
279
end
@@ -340,16 +330,38 @@ def self.regexp(schemes = nil)
340
330
# and then to encoding +enc+.
341
331
#
342
332
# In either case, the returned string has forced encoding Encoding::US_ASCII.
343
- #
344
333
def self . encode_www_form_component ( str , enc = nil )
345
334
_encode_uri_component ( /[^*\- .0-9A-Z_a-z]/ , TBLENCWWWCOMP_ , str , enc )
346
335
end
347
336
348
- # Decodes given +str+ of URL-encoded form data.
337
+ # Returns a string decoded from the given \URL-encoded string +str+.
338
+ #
339
+ # The given string is first encoded as Encoding::ASCII-8BIT (using String#b),
340
+ # then decoded (as below), and finally force-encoded to the given encoding +enc+.
341
+ #
342
+ # The returned string:
343
+ #
344
+ # - Preserves:
345
+ #
346
+ # - Characters <tt>'*'</tt>, <tt>'.'</tt>, <tt>'-'</tt>, and <tt>'_'</tt>.
347
+ # - Character in ranges <tt>'a'..'z'</tt>, <tt>'A'..'Z'</tt>,
348
+ # and <tt>'0'..'9'</tt>.
349
+ #
350
+ # Example:
351
+ #
352
+ # URI.decode_www_form_component('*.-_azAZ09')
353
+ # # => "*.-_azAZ09"
354
+ #
355
+ # - Converts:
356
+ #
357
+ # - Character <tt>'+'</tt> to character <tt>' '</tt>.
358
+ # - Each "percent notation" to an ASCII character.
359
+ #
360
+ # Example:
349
361
#
350
- # This decodes + to SP.
362
+ # URI.decode_www_form_component('Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A')
363
+ # # => "Here are some punctuation characters: ,;?:"
351
364
#
352
- # See URI.encode_www_form_component, URI.decode_www_form.
353
365
def self . decode_www_form_component ( str , enc = Encoding ::UTF_8 )
354
366
_decode_uri_component ( /\+ |%\h \h / , str , enc )
355
367
end
0 commit comments