URL Params

Gets URL Params in object as key-value.

by patelsan

CoffeeScript

window.GetUrlParams = ->
  urlParams = {}
  e = null
  a = /\+/g  #Regex for replacing addition symbol with a space
  r = /([^&=]+)=?([^&]*)/g
  d = (s) -> decodeURIComponent(s.replace(a, " "))
  q = window.location.search.substring(1);

  while (e = r.exec(q))
    urlParams[d(e[1])] = d(e[2])

  urlParams