Created
August 26, 2019 07:38
-
-
Save marqsm/5c491039ebc7cc378457b356e466058e to your computer and use it in GitHub Desktop.
Url params to 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
a.replace('?', '') | |
.split('&') | |
.reduce((accumulator, currentValue) => { | |
const pos = currentValue.indexOf('='); | |
const key = currentValue.slice(0, pos); | |
const value = currentValue.slice(pos+1); | |
accumulator[key] = value; | |
return accumulator; | |
}, {}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment