Skip to content

Commit

Permalink
fix($location): don't clobber path during parsing of path
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorMinar authored and Brady Isom committed Apr 25, 2014
1 parent efa47f8 commit c9b37ae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/ng/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ function LocationHashbangUrl(appBase, hashPrefix) {
Matches paths for file protocol on windows,
such as /C:/foo/bar, and captures only /foo/bar.
*/
var windowsFilePathExp = /^\/?.*?:(\/.*)/;
var windowsFilePathExp = /^\/[A-Z]:(\/.*)/;

var firstPathSegmentMatch;

Expand All @@ -209,10 +209,7 @@ function LocationHashbangUrl(appBase, hashPrefix) {
url = url.replace(base, '');
}

/*
* The input URL intentionally contains a
* first path segment that ends with a colon.
*/
// The input URL intentionally contains a first path segment that ends with a colon.
if (windowsFilePathExp.exec(url)) {
return path;
}
Expand Down
10 changes: 10 additions & 0 deletions test/ng/locationSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1539,6 +1539,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 not strip stuff from path just because it looks like Windows drive when its not',
function() {
location = new LocationHashbangUrl('http://server/pre/index.html', '#');

location.$$parse('http://server/pre/index.html#http%3A%2F%2Fexample.com%2F');
expect(location.url()).toBe('/http://example.com/');
expect(location.absUrl()).toBe('http://server/pre/index.html#/http://example.com/');
});
});


Expand Down

0 comments on commit c9b37ae

Please sign in to comment.