mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-04 21:24:42 +00:00
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
This commit is contained in:
parent
69452fa94f
commit
63cd873fef
2 changed files with 14 additions and 0 deletions
|
|
@ -184,6 +184,10 @@ function LocationHashbangUrl(appBase, hashPrefix) {
|
||||||
|
|
||||||
this.$$compose();
|
this.$$compose();
|
||||||
|
|
||||||
|
if (!this.$$path) {
|
||||||
|
this.$$path = '/';
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In Windows, on an anchor node on documents loaded from
|
* In Windows, on an anchor node on documents loaded from
|
||||||
* the filesystem, the browser will return a pathname
|
* the filesystem, the browser will return a pathname
|
||||||
|
|
|
||||||
|
|
@ -1487,6 +1487,16 @@ describe('$location', function() {
|
||||||
expect(location.url()).toBe('/not-starting-with-slash');
|
expect(location.url()).toBe('/not-starting-with-slash');
|
||||||
expect(location.absUrl()).toBe('http://server/pre/index.html#/not-starting-with-slash');
|
expect(location.absUrl()).toBe('http://server/pre/index.html#/not-starting-with-slash');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it("should return / for path for the application root path", function() {
|
||||||
|
location = new LocationHashbangUrl('http://server/pre/index.html', '#');
|
||||||
|
location.$$parse('http://server/pre/index.html');
|
||||||
|
expect(location.path()).toBe('/');
|
||||||
|
|
||||||
|
location.$$parse('http://server/pre/');
|
||||||
|
expect(location.path()).toBe('/');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue