Method: Bundler::URI.decode_www_form_component

Defined in:
lib/bundler/vendor/uri/lib/uri/common.rb

.decode_www_form_component(str, enc = Encoding::UTF_8) ⇒ Object

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 '*', '.', '-', and '_'.

    • Character in ranges 'a'..'z', 'A'..'Z', and '0'..'9'.

    Example:

    Bundler::URI.decode_www_form_component('*.-_azAZ09')
    # => "*.-_azAZ09"
    
  • Converts:

    • Character '+' to character ' '.

    • Each “percent notation” to an ASCII character.

    Example:

    Bundler::URI.decode_www_form_component('Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A')
    # => "Here are some punctuation characters: ,;?:"
    

Related: Bundler::URI.decode_uri_component (preserves '+').



395
396
397
# File 'lib/bundler/vendor/uri/lib/uri/common.rb', line 395

def self.decode_www_form_component(str, enc=Encoding::UTF_8)
  _decode_uri_component(/\+|%\h\h/, str, enc)
end