diff --git a/core/modules/views/js/base.js b/core/modules/views/js/base.js index e7aa903..378784f 100644 --- a/core/modules/views/js/base.js +++ b/core/modules/views/js/base.js @@ -12,21 +12,28 @@ * Helper function to parse a querystring. */ Drupal.Views.parseQueryString = function (query) { - var args = {}; var pos = query.indexOf('?'); if (pos !== -1) { query = query.substring(pos + 1); } + + var re = /([^&=]+)=?([^&#]*)/g; + var params = {}; var pair; - var pairs = query.split('&'); - for (var i = 0; i < pairs.length; i++) { - pair = pairs[i].split('='); - // Ignore the 'q' path argument, if present. - if (pair[0] !== 'q' && pair[1]) { - args[decodeURIComponent(pair[0].replace(/\+/g, ' '))] = decodeURIComponent(pair[1].replace(/\+/g, ' ')); + while (pair = re.exec(query)) { + var k = decodeURIComponent(pair[1].replace(/\+/g, " ")); + var v = decodeURIComponent(pair[2].replace(/\+/g, " ")); + if (typeof params[k] !== 'undefined') { + if (!Array.isArray(params[k])) { + params[k] = [params[k]]; + } + params[k].push(v); + } + else { + params[k] = v; } } - return args; + return params; }; /**