Created
May 28, 2019 03:21
-
-
Save sean-gilmore/2b8dc90c59115a108532b4b91695d474 to your computer and use it in GitHub Desktop.
Vanilla.js Query String parse
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 getQueryParams() { | |
var qd = {}; | |
if (location.search) { | |
location.search.substr(1).split("&").forEach(function(item) { | |
var s = item.split("="), | |
k = s[0], | |
v = s[1] && decodeURIComponent(s[1]); | |
(qd[k] = qd[k] || []).push(v) | |
}) | |
} | |
return qd; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment