module URI
Public Class Methods
params_hash(uri)
click to toggle source
Extracts a ruby hash from the URI
query string
# File lib/arctic/vendor/uri.rb, line 11 def self.params_hash(uri) Hash[CGI.parse(uri.query).collect { |k, v| [k, v.join('')] }] end
replace_params(url, new_params)
click to toggle source
Merges the `new_params` with the existing query parameters from the `url`
# File lib/arctic/vendor/uri.rb, line 3 def self.replace_params(url, new_params) uri = parse url params = params_hash(uri).merge new_params new_url = "#{uri.scheme}://#{uri.host}#{uri.path}?#{new_params.to_query}##{uri.fragment}" parse new_url end