Requires

Provides

String.QueryString.js

Methods for dealing with URI query strings.

License:
MIT-style license
Authors:
Sebastian Markbåge, Aaron Newton, Lennart Pilon, Valerio Proietti
  1. 26
  2. 27
  3. 28
  4. 29
  5. 30
  6. 31
  7. 32
  8. 33
  9. 34
  10. 35
  11. 36
  12. 37
  13. 38
  14. 39
  15. 40
  16. 41
  17. 42
  18. 43
  19. 44
  20. 45
  21. 46
  22. 47
  23. 48
  24. 49
  25. 50
  26. 51
  27. 52
  28. 53
  29. 54
  30. 55
  31. 56
  32. 57
  33. 58
  34. 59
  35. 60
  36. 61
  37. 62
  38. 63
  39. 64
  40. 65
  41. 66
  42. 67
String.implement({ parseQueryString: function(){ var vars = this.split(/[&;]/), res = {}; if (vars.length){ vars.each(function(val){ var index = val.indexOf('='), keys = index < 0 ? [''] : val.substr(0, index).match(/[^\]\[]+/g), value = decodeURIComponent(val.substr(index + 1)), obj = res; keys.each(function(key, i){ var current = obj[key]; if (i < keys.length - 1){ obj = obj[key] = current || {}; } else if (typeOf(current) == 'array'){ current.push(value); } else { obj[key] = current != null ? [current, value] : value; } }); }); } return res; }, cleanQueryString: function(method){ return this.split('&').filter(function(val){ var index = val.indexOf('='), key = index < 0 ? '' : val.substr(0, index), value = val.substr(index + 1); return method ? method.run([key, value]) : (value || value === 0); }).join('&'); } });