diff --git a/src/ng/location.js b/src/ng/location.js index 0a47445f6f87..d193b1ca667e 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 ff823d306efd..b66f689b725a 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('/'); + }); });