diff options
Diffstat (limited to 'plugins/CoreHome/angularjs/history/history.service.js')
-rw-r--r-- | plugins/CoreHome/angularjs/history/history.service.js | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/plugins/CoreHome/angularjs/history/history.service.js b/plugins/CoreHome/angularjs/history/history.service.js index 2c6486a517..7dadf35ad0 100644 --- a/plugins/CoreHome/angularjs/history/history.service.js +++ b/plugins/CoreHome/angularjs/history/history.service.js @@ -36,6 +36,19 @@ loadCurrentPage(); } + function cleanHash(hash) + { + var chars = ['#', '/', '?']; + for (var i = 0; i != chars.length; ++i) { + var charToRemove = chars[i]; + if (hash.charAt(0) == charToRemove) { + hash = hash.substring(1); + } + } + + return hash; + } + // currently, the AJAX content URL is stored in $location.search(), but before it was stored in $location.path(). // this function makes sure URLs like http://piwik.net/?...#/module=Whatever&action=whatever still work. function changePathToSearch() { @@ -82,13 +95,7 @@ function load(hash) { // make sure the hash is just the query parameter values, w/o a starting #, / or ? char. broadcast.pageload & $location.path should get neither - var chars = ['#', '/', '?']; - for (var i = 0; i != chars.length; ++i) { - var charToRemove = chars[i]; - if (hash.charAt(0) == charToRemove) { - hash = hash.substring(1); - } - } + hash = cleanHash(hash); if (location.hash === '#?' + hash) { loadCurrentPage(); // it would not trigger a location change success event as URL is the same, call it manually |