diff options
| author | Caitlin Potter | 2014-01-09 14:19:41 -0500 |
|---|---|---|
| committer | Igor Minar | 2014-01-09 17:35:25 -0800 |
| commit | 63cd873fef3207deef30c7a7ed66f4b8f647dc12 (patch) | |
| tree | ef9afc869c076a7d39d159034b903634b8a922dc | |
| parent | 69452fa94f32c0e535d035988204e28eeda048a1 (diff) | |
| download | angular.js-63cd873fef3207deef30c7a7ed66f4b8f647dc12.tar.bz2 | |
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
| -rw-r--r-- | src/ng/location.js | 4 | ||||
| -rw-r--r-- | test/ng/locationSpec.js | 10 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/ng/location.js b/src/ng/location.js index 0a47445f..d193b1ca 100644 --- a/src/ng/location.js +++ b/src/ng/location.js @@ -184,6 +184,10 @@ function LocationHashbangUrl(appBase, hashPrefix) { this.$$compose(); + if (!this.$$path) { + this.$$path = '/'; + } + /* * In Windows, on an anchor node on documents loaded from * the filesystem, the browser will return a pathname diff --git a/test/ng/locationSpec.js b/test/ng/locationSpec.js index ff823d30..b66f689b 100644 --- a/test/ng/locationSpec.js +++ b/test/ng/locationSpec.js @@ -1487,6 +1487,16 @@ describe('$location', function() { expect(location.url()).toBe('/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('/'); + }); }); |
