From d18b2819768e467897dee7bc223876ca23ea71b1 Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Tue, 19 Aug 2014 21:17:48 -0400 Subject: [PATCH] fix($location): rewrite relative URI correctly if path==='/' in legacy html5Mode Currently, legacy browsers get to use a clever scheme for resolving relative URIs in html5Mode, and resolve the URI relative to $location.path(). Currently, $location.path() can be '/' under certain circumstances, which means that when we split $location.path() on '/' and later join by '/' after adding another path component, we end up with '//pathComponent'. $$rewrite fails to deal with this correctly, and effectively the $location is never changed from the root path. This CL corrects this by ensuring that the duplicate '/' situation does not occur when resolving relative URIs. Closes #8684 --- src/ng/location.js | 1 + test/ng/locationSpec.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/ng/location.js b/src/ng/location.js index 664a9ee0b4cb..98dec092dd26 100644 --- a/src/ng/location.js +++ b/src/ng/location.js @@ -682,6 +682,7 @@ function $LocationProvider(){ // relative path - join with current path var stack = $location.path().split("/"), parts = href.split("/"); + if (stack.length === 2 && !stack[1]) stack.length = 1; for (var i=0; i