Sha256: 7525c7602f7fb9cb5754afef4cade350e3864a28051e5f83143a96f2aef55c37
Contents?: true
Size: 473 Bytes
Versions: 7
Compression:
Stored size: 473 Bytes
Contents
module URI # Merges the `new_params` with the existing query parameters from the `url` 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 # Extracts a ruby hash from the URI query string def self.params_hash(uri) Hash[CGI.parse(uri.query).collect { |k, v| [k, v.join('')] }] end end
Version data entries
7 entries across 7 versions & 1 rubygems