Created
November 21, 2019 01:13
-
-
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
This file contains 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
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