Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Access the query parameters of a URI, just like $_GET in PHP.
Ruby
Branch: master
Failed to load latest commit information.
lib/uri Override URI::Generic#to_s so it always calls our query method.
spec Override URI::Generic#to_s so it always calls our query method.
.document Added a .document file.
.gitignore Use bundler to manage our four dependencies.
.rspec
.travis.yml Shorten versions so RVM picks the most recent.
.yardopts Removed the --quiet option.
ChangeLog.md Updated the ChangeLog.
Gemfile Moved all development dependencies into the Gemfile.
LICENSE.txt Bump the copyright dates.
README.md Use https:// URIs.
Rakefile Use bundler to manage our four dependencies.
gemspec.yml
uri-query_params.gemspec Use the new pure-Ruby gemspec from Ore 0.8.0.

README.md

URI query_params

Build Status

Description

Allows access to the query component of the URI as a Hash. This is similar to $_GET from PHP, except available on any Ruby URI object.

Examples

Inspecting the URI query_params:

require 'uri/query_params'

url = URI('http://www.google.com/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=1HY&q=bob+ross&btnG=Search')
url.query_params
# => {"btnG"=>"Search", "hs"=>"1HY", "rls"=>"org.mozilla:en-US:official", "client"=>"firefox-a", "hl"=>"en", "q"=>"bob+ross"}

url.query_params['q']
# => "bob+ross"

Setting the URI query_params:

url.query_params['q'] = 'Upright Citizens Brigade'
url.to_s
# => "http://www.google.com/search?btnG=Search&hs=1HY&rls=org.mozilla:en-US:official&client=firefox-a&hl=en&q=Upright%20Citizens%20Brigade"

Parsing URI query_params embedded within the Fragment Identifier:

url = URI('https://twitter.com/#!/download?lang=en&logged_out=1')
URI(url.fragment).query_params
# => {"logged_out"=>"1", "lang"=>"en"}

Install

$ gem install uri-query_params

License

Copyright (c) 2010-2015 Hal Brodigan

See {file:LICENSE.txt} for license information.

Something went wrong with that request. Please try again.