Last active
April 23, 2017 02:19
-
-
Save alexsasharegan/94bc7a7cdf811fcf1979f56fad793a7f to your computer and use it in GitHub Desktop.
Glorious usage of ES2015 to parse uri-encoded strings to plain javascript objects.
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
| function decodeQueryStringToObj( qStr ) { | |
| return Object.assign.apply( null, qStr.split( '&' ).map( pair => { | |
| const [ key, val ] = pair.split( '=' ).map( decodeURIComponent ) | |
| return { [key]: val } | |
| } ) ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment