Created
October 15, 2015 19:58
-
-
Save zbicin/72aa8fc4c3e97f7321bc to your computer and use it in GitHub Desktop.
A snippet serving URL parameters as an object
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 parseUrlParameters() { | |
| var result = {}; | |
| var keyValueCombined = location.search.substr(1).split('&'); | |
| for(var i = 0; i<keyValueCombined.length; i++) { | |
| var splitted = keyValueCombined[i].split('='); | |
| var key = splitted[0]; | |
| var value = splitted.slice(1).join('='); | |
| result[key] = value; | |
| } | |
| if(result[''] !== undefined && result[''] === '') { | |
| delete result['']; | |
| } | |
| return result; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment