Skip to content

Commit 52f2ed8

Browse files
committed
Merge pull request #6 from megapctr/master
Adds very basic array parsing.
2 parents eaea106 + 3d3fcfc commit 52f2ed8

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

jquery.querystring.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,19 @@
3737
}
3838

3939
$.each(query.split('&'), function(idx, pair) {
40+
var key, value, oldValue;
4041
pair = pair.split('=');
41-
params[pair[0]] = parseValue(pair[1] || '');
42+
key = pair[0].replace('[]', ''); // FIXME
43+
value = parseValue(pair[1] || '');
44+
if (params.hasOwnProperty(key)) {
45+
if (!params[key].push) {
46+
oldValue = params[key];
47+
params[key] = [oldValue];
48+
}
49+
params[key].push(value);
50+
} else {
51+
params[key] = value;
52+
}
4253
});
4354

4455
return params;

0 commit comments

Comments
 (0)