Skip to content

Instantly share code, notes, and snippets.

@sean-gilmore
Created May 28, 2019 03:21
Show Gist options
  • Save sean-gilmore/2b8dc90c59115a108532b4b91695d474 to your computer and use it in GitHub Desktop.
Save sean-gilmore/2b8dc90c59115a108532b4b91695d474 to your computer and use it in GitHub Desktop.
Vanilla.js Query String parse
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