Skip to content

Instantly share code, notes, and snippets.

@greystate
Created October 10, 2011 09:50
Show Gist options
  • Save greystate/1274961 to your computer and use it in GitHub Desktop.
Save greystate/1274961 to your computer and use it in GitHub Desktop.
CoffeeScript QueryString class
# Provide easy access to QueryString data
class QueryString
constructor: (@queryString) ->
@queryString or= window.document.location.search?.substr 1
@variables = @queryString.split '&'
@pairs = ([key, value] = pair.split '=' for pair in @variables)
get: (name) ->
for [key, value] in @pairs
return value if key is name
@MrJoy
Copy link

MrJoy commented Jul 29, 2013

All you need to do to address decoding is run both key and value through decodeURIComponent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment