I hereby claim:
- I am dolarsrg on github.
- I am dolarsrg (https://keybase.io/dolarsrg) on keybase.
- I have a public key ASArLGiaCIRcowQJ4w2KmsO-JPN2BO1xmfN2P9LYghr7Jgo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
# Takes an url, detects its params and adds to it the vars from the hash | |
# Example of use: | |
# > add_url_vars("http://www.example.com/signup?token=HIWORLD", {:s => 'HIAGAIN', :s32 => 'BYE'}) | |
# => "http://www.example.com/signup?token=HIWORLD&s=HIAGAIN&s32=BYE" | |
def add_url_vars(url, vars={}) | |
uri = URI.parse(url) | |
pre_vars = get_url_vars(url) | |
vars_total = [] | |
for var in pre_vars | |
vars_total << "#{var[0]}=#{var[1][0]}" |
# Returns a hash with the name of the vars linked to an array with all the values of it | |
def get_url_vars(url) | |
require 'uri' | |
require 'cgi' | |
uri = URI.parse(url).query | |
if uri and (url = CGI.parse(uri)) | |
return url | |
else | |
return nil | |
end |