Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'uri'
url = 'http://example.com?foo=1&bar=2'
uri = URI.parse(url)
decoded_query = URI.decode_www_form(uri.query)
pp decoded_query, decoded_query.class
decoded_query_hash = Hash[decoded_query]
pp decoded_query_hash, decoded_query_hash.class
@kyanny

This comment has been minimized.

Copy link
Owner Author

@kyanny kyanny commented Aug 22, 2021

❯ ruby uri.rb
[["foo", "1"], ["bar", "2"]]
Array
{"foo"=>"1", "bar"=>"2"}
Hash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment