Created
May 8, 2014 14:26
-
-
Save obihann/4c8e8360b0cef1e7ec41 to your computer and use it in GitHub Desktop.
CoffeeScript URL Parser
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
getURLParameters = (url) -> | |
result = {} | |
searchIndex = url.indexOf("?") | |
result if searchIndex is -1 | |
sPageURL = url.substring(searchIndex + 1) | |
sURLVariables = sPageURL.split("&") | |
i = 0 | |
while i < sURLVariables.length | |
sParameterName = sURLVariables[i].split("=") | |
result[sParameterName[0]] = sParameterName[1] | |
i++ | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment