Skip to content

Instantly share code, notes, and snippets.

@dominikbulaj
Created March 23, 2018 09:17
Show Gist options
  • Save dominikbulaj/600f5f856c476e650ac8b803c3cbaaf4 to your computer and use it in GitHub Desktop.
Save dominikbulaj/600f5f856c476e650ac8b803c3cbaaf4 to your computer and use it in GitHub Desktop.
Simple code to get URL searchParams as key-value object
location.search.substr(1)
.split('&')
.reduce((ac, cur) => {
if (cur) {
const kv = cur.split('=')
ac[kv[0]] = decodeURIComponent(kv[1].replace(/\+/g, ' '))
}
return ac
}, {})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment