Skip to content

Instantly share code, notes, and snippets.

@konsumer
Created November 21, 2019 01:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save konsumer/007f0a3371731cb10513df71cb42d693 to your computer and use it in GitHub Desktop.
Save konsumer/007f0a3371731cb10513df71cb42d693 to your computer and use it in GitHub Desktop.
take a url string (eg from document.location.search) like `cool=1&neat=true` and turn it into an object
const parseURIObj = str => str.split('&').reduce((a, c) => { const v = c.split('='); return { ...a, [decodeURI(v[0])]: decodeURI(v[1]) } }, {})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment