Skip to content

Instantly share code, notes, and snippets.

@billychan
Created February 9, 2014 04:28
Show Gist options
  • Save billychan/8894271 to your computer and use it in GitHub Desktop.
Save billychan/8894271 to your computer and use it in GitHub Desktop.
Parse query string in Javascript
# Raw Javascript functions
window.parseQueryString = ->
query = (window.location.search || '?').substr(1)
map = {}
query.replace(/([^&=]+)=?([^&]*)(?:&+|$)/g, (match, key, value) ->
(map[key] = map[key] || []).push(value)
)
return map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment