Last active
January 31, 2017 16:35
-
-
Save artursopelnik/0fbd7c146fc4c8baa37e661e6e32cb95 to your computer and use it in GitHub Desktop.
get url parameter
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
function parseQueryString () { | |
var str = window.location.search, | |
objURL = {}, | |
isArray = _.isArray, | |
first; | |
str.replace( | |
new RegExp('([^?=&]+)(=([^&]*))?', 'g'), | |
function ($0, $1, $2, $3) { | |
if (objURL[$1] && !isArray(objURL[$1])) { | |
first = objURL[$1]; | |
objURL[$1] = [first, $3]; | |
} else if (objURL[$1] && isArray(objURL[$1])) { | |
objURL[$1].push($3); | |
} else { | |
objURL[$1] = $3; | |
} | |
} | |
); | |
return objURL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment