Skip to content

Instantly share code, notes, and snippets.

@DaveKin
Created May 3, 2016 13:18
Show Gist options
  • Save DaveKin/16f8cd00677603a54aed2c6bc31227ad to your computer and use it in GitHub Desktop.
Save DaveKin/16f8cd00677603a54aed2c6bc31227ad to your computer and use it in GitHub Desktop.
function to parse the querystring into a JSON object
export function() {
var items = location.search.slice(1).split('&');
var obj = {};
items.forEach(function(item) {
item = item.split('=');
obj[item[0]] = decodeURIComponent(item[1] || '');
});
return JSON.parse(JSON.stringify(obj));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment