Skip to content

Instantly share code, notes, and snippets.

@curt
Created February 9, 2010 02:04
Show Gist options
  • Save curt/298846 to your computer and use it in GitHub Desktop.
Save curt/298846 to your computer and use it in GitHub Desktop.
Return URI query parameters as hash
class URI::Generic
def query_params
Hash[(query || '').split('&').collect{ |a| a.split('=') }.collect{ |b| [URI.unescape(b[0]), b[1].nil? ? nil : URI.unescape(b[1])] }]
end
alias_method :query_parameters, :query_params
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment