diff options
author | diosmosis <benaka@piwik.pro> | 2015-10-16 04:01:03 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-10-16 04:01:03 +0300 |
commit | 55a1d647312c03a7070c693006079af535e4953d (patch) | |
tree | 31fbdb971d0ac449b6ff0be9ac538d548e77f564 /plugins/CoreHome | |
parent | 60bd87fb4834b33fd4744a071ee4cf35056010e2 (diff) |
Normalize current hash value before comparing w/ current so all equivalent hash URLs will be treated as equal.
Diffstat (limited to 'plugins/CoreHome')
-rw-r--r-- | plugins/CoreHome/angularjs/history/history.service.js | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/plugins/CoreHome/angularjs/history/history.service.js b/plugins/CoreHome/angularjs/history/history.service.js index 2c6486a517..fdad7667ac 100644 --- a/plugins/CoreHome/angularjs/history/history.service.js +++ b/plugins/CoreHome/angularjs/history/history.service.js @@ -82,15 +82,10 @@ 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); - } - } - - if (location.hash === '#?' + hash) { + hash = normalizeHash(hash); + + var currentHash = normalizeHash(location.hash); + if (currentHash === hash) { loadCurrentPage(); // it would not trigger a location change success event as URL is the same, call it manually } else if (hash) { $location.search(hash); @@ -104,5 +99,16 @@ setTimeout(function () { $rootScope.$apply(); }, 1); } + + function normalizeHash(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; + } } })(window, jQuery, broadcast); |