Created
February 29, 2012 15:51
-
-
Save dolarsrg/1941926 to your computer and use it in GitHub Desktop.
Function to extract variables from an URL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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