Method: URI#query_param
- Defined in:
- lib/grubby/core_ext/uri.rb
#query_param(name) ⇒ String, ...
Returns the value of the specified query param in the URI's query
string. The specified name must be exactly as it appears in the
query string, and support for complex nested values is limited.
(See CGI.parse for parsing behavior.) If name contains "[]",
all occurrences of the query param are returned as an Array.
Otherwise, only the last occurrence is returned.
38 39 40 41 |
# File 'lib/grubby/core_ext/uri.rb', line 38 def query_param(name) values = CGI.parse(self.query)[name] if self.query (values.nil? || name.include?("[]")) ? values : values.last end |