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

fix($location): return '/' for root path in hashbang mode #5712

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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