Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiosmosis <benaka@piwik.pro>2015-09-22 04:28:12 +0300
committerdiosmosis <benaka@piwik.pro>2015-09-22 04:28:12 +0300
commit73f72ebd2c471a395ee5bc86e98b0b4ba1007fbd (patch)
tree089e8f8a28ef5303b9dc1299cbd136fa40924e14 /plugins/CoreHome/angularjs/history
parentef58eb16085d367fc3806d731e4cd76db055f77a (diff)
When converting the angular result to a query string, make sure to take into account angular's behavior when multiple query parameters w/ the same name exist (ie, use the last one angular sees instead of using an array).
Diffstat (limited to 'plugins/CoreHome/angularjs/history')
-rw-r--r--plugins/CoreHome/angularjs/history/history.service.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/plugins/CoreHome/angularjs/history/history.service.js b/plugins/CoreHome/angularjs/history/history.service.js
index 2f8499df51..828217a5fa 100644
--- a/plugins/CoreHome/angularjs/history/history.service.js
+++ b/plugins/CoreHome/angularjs/history/history.service.js
@@ -57,6 +57,16 @@
var searchObject = $location.search(),
searchString = [];
for (var name in searchObject) {
+ if (!searchObject.hasOwnProperty(name)) {
+ continue;
+ }
+
+ // if more than one query parameter of the same name is supplied, angular will return all of them as
+ // an array. we only want to use the last one, though.
+ if (searchObject[name] instanceof Array) {
+ searchObject[name] = searchObject[name][searchObject[name].length - 1];
+ }
+
searchString.push(name + '=' + encodeURIComponent(searchObject[name]));
}
searchString = searchString.join('&');