Module: Witness

Defined in:
lib/witness/base.rb,
lib/witness/error.rb,
lib/witness/version.rb,
lib/witness/utilities.rb

Defined Under Namespace

Classes: Base, Error

Constant Summary collapse

VERSION =
"2.1.2"

Class Method Summary collapse

Class Method Details

.update_url(url, new_params) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/witness/utilities.rb', line 3

def self.update_url(url, new_params)
  uri = URI.parse(url)
  query = uri.query
  params = Rack::Utils.parse_nested_query(query).symbolize_keys
  uri.path = "/" if uri.path == ""
  uri.scheme = "http" if uri.scheme.nil?
  uri.query = params.update(new_params).to_query
  uri.to_s
rescue
  nil
end