Skip to content

Instantly share code, notes, and snippets.

@dolarsrg
Created February 29, 2012 15:51
Show Gist options
  • Save dolarsrg/1941926 to your computer and use it in GitHub Desktop.
Save dolarsrg/1941926 to your computer and use it in GitHub Desktop.
Function to extract variables from an URL
# 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
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment