fix($location): don't clobber path during parsing of path

Closes #7199
This commit is contained in:
Igor Minar
2014-04-24 13:48:45 -07:00
parent 76647d3855
commit 02058bfbe2
2 changed files with 12 additions and 5 deletions

View File

@@ -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;
@@ -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;
}

View File

@@ -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/');
});
});