diff --git a/src/ng/location.js b/src/ng/location.js index 3caa14e8de61..522154514ca1 100644 --- a/src/ng/location.js +++ b/src/ng/location.js @@ -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; } diff --git a/test/ng/locationSpec.js b/test/ng/locationSpec.js index 37b78af0b6ea..979993156880 100644 --- a/test/ng/locationSpec.js +++ b/test/ng/locationSpec.js @@ -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/'); + }); });