Created
May 3, 2016 13:18
-
-
Save DaveKin/16f8cd00677603a54aed2c6bc31227ad to your computer and use it in GitHub Desktop.
function to parse the querystring into a JSON object
This file contains hidden or 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
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