Created
September 4, 2014 17:45
-
-
Save imcodetolive/e161103b158109812883 to your computer and use it in GitHub Desktop.
Convert URL parameters to a javascript object
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
define(function(){ | |
"use strict"; | |
var parseURLParams; | |
parseURLParams = function(str){ | |
var obj; | |
obj = {}; | |
if (!str) return obj; | |
str.replace(/([^=&]+)=([^&]*)/g, function(m, key, value){ | |
obj[key] = (obj[key] ? obj[key] + "," : "") + value; | |
}); | |
return obj; | |
}; | |
return parseURLParams; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment