fix(Router): replace state when normalized path is equal to current normalized path

Make sure the same path is not added multiple times to the history.
It is replacing the state, instead of skipping it completely,
because the current path in the browser might not be normalized,
while the given one is normalized.

Closes #7829

Closes #7897
This commit is contained in:
Rene Weber
2016-04-08 01:02:07 +01:00
committed by Misko Hevery
parent 9105ab9596
commit 2bf21e1747
5 changed files with 52 additions and 3 deletions

View File

@ -313,9 +313,18 @@ Location.prototype.subscribe = function () {
Location.prototype.path = function () {
return $location.url();
};
Location.prototype.isCurrentPathEqualTo = function (path, query) {
if (query === void 0) { query = ''; }
return this.path() === (path + query);
};
Location.prototype.go = function (path, query) {
return $location.url(path + query);
};
Location.prototype.replaceState = function (path, query) {
if (query === void 0) { query = ''; }
$location.url(path + query);
$location.replace();
};
Location.prototype.prepareExternalUrl = function(url) {
if (url.length > 0 && !url.startsWith('/')) {
url = '/' + url;