module Bundler::URI

def self.decode_www_form_component(str, enc=Encoding::UTF_8)

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

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

Example:

- Each "percent notation" to an ASCII character.
- Character '+' to character ' '.

- Converts:

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

Example:

and '0'..'9'.
- Character in ranges 'a'..'z', 'A'..'Z',
- Characters '*', '.', '-', and '_'.

- Preserves:

The returned string:

then decoded (as below), and finally force-encoded to the given encoding +enc+.
The given string is first encoded as Encoding::ASCII-8BIT (using String#b),

Returns a string decoded from the given \URL-encoded string +str+.
def self.decode_www_form_component(str, enc=Encoding::UTF_8)
  _decode_uri_component(/\+|%\h\h/, str, enc)
end