Skip to content

Instantly share code, notes, and snippets.

@obihann
Created May 8, 2014 14:26
Show Gist options
  • Save obihann/4c8e8360b0cef1e7ec41 to your computer and use it in GitHub Desktop.
Save obihann/4c8e8360b0cef1e7ec41 to your computer and use it in GitHub Desktop.
CoffeeScript URL Parser
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