Skip to content

Commit 7dfea06

Browse files
AC-386: Update Third Party library: jquery.parsequery
1 parent fa1824e commit 7dfea06

File tree

1 file changed

+18
-23
lines changed

1 file changed

+18
-23
lines changed

lib/web/jquery/jquery.parsequery.js

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66
*
77
* See the README for details.
88
**/
9-
/*jshint jquery:true */
10-
/*global window:true */
119
define([
1210
"jquery"
1311
], function($){
12+
$.parseQuery = function (options) {
1413

15-
$.parseQuery = function(options) {
1614
var config = {query: window.location.search || ""},
1715
params = {};
1816

@@ -22,30 +20,27 @@ define([
2220
$.extend(config, $.parseQuery, options);
2321
config.query = config.query.replace(/^\?/, '');
2422

25-
$.each(config.query.split(config.separator), function(i, param) {
26-
var pair = param.split('='),
27-
key = config.decode(pair.shift(), null).toString(),
28-
value = config.decode(pair.length ? pair.join('=') : null, key);
29-
30-
if (config.array_keys(key)) {
31-
params[key] = params[key] || [];
32-
params[key].push(value);
33-
} else {
34-
params[key] = value;
35-
}
36-
});
37-
23+
if (config.query.length > 0) {
24+
$.each(config.query.split(config.separator), function (i, param) {
25+
var pair = param.split('='),
26+
key = config.decode(pair.shift(), null).toString(),
27+
value = config.decode(pair.length ? pair.join('=') : null, key);
28+
29+
if (config.array_keys.test ? config.array_keys.test(key) : config.array_keys(key)) {
30+
params[key] = params[key] || [];
31+
params[key].push(value);
32+
} else {
33+
params[key] = value;
34+
}
35+
});
36+
}
3837
return params;
3938
};
40-
41-
$.parseQuery.decode = $.parseQuery.default_decode = function(string) {
42-
return decodeURIComponent((string || "").replace('+', ' '));
39+
$.parseQuery.decode = $.parseQuery.default_decode = function (string) {
40+
return decodeURIComponent((string || "").replace(/\+/g, ' '));
4341
};
44-
45-
$.parseQuery.array_keys = function() {
42+
$.parseQuery.array_keys = function () {
4643
return false;
4744
};
48-
4945
$.parseQuery.separator = "&";
50-
5146
});

0 commit comments

Comments
 (0)