I have just created a simple jQuery plugin to add the opposite functionality to the jQuery.param function. It will turn a set of url parameters back in to an object. Here’s the usage at the moment.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
it("should get basic query string vars from full url",function(){expect(jQuery.unparam('https://davetayls.me/?foo=one&bar=two')).toEqual({foo:"one",bar:"two"});});it("should get basic query string vars from just query params",function(){expect(jQuery.unparam('foo=one&bar=two')).toEqual({foo:"one",bar:"two"});});