Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 63cd873

Browse files
caitpIgorMinar
authored andcommitted
fix($location): return '/' for root path in hashbang mode
Before this change, on the root of the application, $location.path() would return the empty string. Following this change, it will always return a root of '/'. Closes #5650 Closes #5712
1 parent 69452fa commit 63cd873

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/ng/location.js

+4
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ function LocationHashbangUrl(appBase, hashPrefix) {
184184

185185
this.$$compose();
186186

187+
if (!this.$$path) {
188+
this.$$path = '/';
189+
}
190+
187191
/*
188192
* In Windows, on an anchor node on documents loaded from
189193
* the filesystem, the browser will return a pathname

test/ng/locationSpec.js

+10
Original file line numberDiff line numberDiff line change
@@ -1487,6 +1487,16 @@ describe('$location', function() {
14871487
expect(location.url()).toBe('/not-starting-with-slash');
14881488
expect(location.absUrl()).toBe('http://server/pre/index.html#/not-starting-with-slash');
14891489
});
1490+
1491+
1492+
it("should return / for path for the application root path", function() {
1493+
location = new LocationHashbangUrl('http://server/pre/index.html', '#');
1494+
location.$$parse('http://server/pre/index.html');
1495+
expect(location.path()).toBe('/');
1496+
1497+
location.$$parse('http://server/pre/');
1498+
expect(location.path()).toBe('/');
1499+
});
14901500
});
14911501

14921502

0 commit comments

Comments
 (0)