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

Commit 02058bf

Browse files
committed
fix($location): don't clobber path during parsing of path
Closes #7199
1 parent 76647d3 commit 02058bf

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/ng/location.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ function LocationHashbangUrl(appBase, hashPrefix) {
200200
Matches paths for file protocol on windows,
201201
such as /C:/foo/bar, and captures only /foo/bar.
202202
*/
203-
var windowsFilePathExp = /^\/?.*?:(\/.*)/;
203+
var windowsFilePathExp = /^\/[A-Z]:(\/.*)/;
204204

205205
var firstPathSegmentMatch;
206206

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

212-
/*
213-
* The input URL intentionally contains a
214-
* first path segment that ends with a colon.
215-
*/
212+
// The input URL intentionally contains a first path segment that ends with a colon.
216213
if (windowsFilePathExp.exec(url)) {
217214
return path;
218215
}

test/ng/locationSpec.js

+10
Original file line numberDiff line numberDiff line change
@@ -1539,6 +1539,16 @@ describe('$location', function() {
15391539
expect(location.url()).toBe('/not-starting-with-slash');
15401540
expect(location.absUrl()).toBe('http://server/pre/index.html#/not-starting-with-slash');
15411541
});
1542+
1543+
1544+
it('should not strip stuff from path just because it looks like Windows drive when its not',
1545+
function() {
1546+
location = new LocationHashbangUrl('http://server/pre/index.html', '#');
1547+
1548+
location.$$parse('http://server/pre/index.html#http%3A%2F%2Fexample.com%2F');
1549+
expect(location.url()).toBe('/http://example.com/');
1550+
expect(location.absUrl()).toBe('http://server/pre/index.html#/http://example.com/');
1551+
});
15421552
});
15431553

15441554

0 commit comments

Comments
 (0)