Skip to content

Commit

Permalink
fix($location): return '/' for root path in hashbang mode
Browse files Browse the repository at this point in the history
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 angular#5650
Closes angular#5712
  • Loading branch information
caitp authored and jamesdaily committed Jan 27, 2014
1 parent d132063 commit eb6ddc8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/ng/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions test/ng/locationSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('/');
});
});


Expand Down

0 comments on commit eb6ddc8

Please sign in to comment.