https://github.com/postmodern/uri-query_params
Access the query parameters of a URI, just like $_GET in PHP.
https://github.com/postmodern/uri-query_params
core-ext params query-params query-params-parsing ruby uri
Last synced: 5 months ago
JSON representation
Access the query parameters of a URI, just like $_GET in PHP.
- Host: GitHub
- URL: https://github.com/postmodern/uri-query_params
- Owner: postmodern
- License: mit
- Created: 2010-08-29T00:25:56.000Z (almost 15 years ago)
- Default Branch: main
- Last Pushed: 2024-01-25T10:06:37.000Z (over 1 year ago)
- Last Synced: 2024-05-01T22:03:38.595Z (about 1 year ago)
- Topics: core-ext, params, query-params, query-params-parsing, ruby, uri
- Language: Ruby
- Homepage:
- Size: 102 KB
- Stars: 16
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# URI query_params
* [Source](https://github.com/postmodern/uri-query_params)
* [Issues](https://github.com/postmodern/uri-query_params/issues)
* [Documentation](http://rubydoc.info/gems/uri-query_params/frames)## 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:
```ruby
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:
```ruby
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:
```ruby
url = URI('https://twitter.com/#!/download?lang=en&logged_out=1')
URI(url.fragment).query_params
# => {"logged_out"=>"1", "lang"=>"en"}
```## Requirements
* [ruby] >= 2.0.0
## Install
```shell
$ gem install uri-query_params
```## License
See {file:LICENSE.txt} for license information.
[ruby]: https://www.ruby-lang.org/