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

Commit 3b0ac77

Browse files
committed
fix($location): prevent infinite digest with IDN urls in Edge
Internationalized Domain Urls, for example Urls with Umlaut (Ä, Ö, Ü) cause infinite digest in Edge 38.14393.0.0 because lastIndexOf doesn't work correctly in this version. indexOf does, though. Fixes #15217
1 parent faf0c3e commit 3b0ac77

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/ng/location.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function parseAppUrl(relativeUrl, locationObj) {
4949
}
5050

5151
function startsWith(haystack, needle) {
52-
return haystack.lastIndexOf(needle, 0) === 0;
52+
return haystack.indexOf(needle) === 0;
5353
}
5454

5555
/**

test/ng/locationSpec.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -2450,10 +2450,11 @@ describe('$location', function() {
24502450

24512451

24522452
describe('LocationHtml5Url', function() {
2453-
var locationUrl, locationIndexUrl;
2453+
var locationUrl, locationUmlautUrl, locationIndexUrl;
24542454

24552455
beforeEach(function() {
24562456
locationUrl = new LocationHtml5Url('http://server/pre/', 'http://server/pre/', 'http://server/pre/path');
2457+
locationUmlautUrl = new LocationHtml5Url('http://särver/pre/', 'http://särver/pre/', 'http://särver/pre/path');
24572458
locationIndexUrl = new LocationHtml5Url('http://server/pre/index.html', 'http://server/pre/', 'http://server/pre/path');
24582459
});
24592460

@@ -2465,6 +2466,13 @@ describe('$location', function() {
24652466
// Note: relies on the previous state!
24662467
expect(parseLinkAndReturn(locationUrl, 'someIgnoredAbsoluteHref', '#test')).toEqual('http://server/pre/otherPath#test');
24672468

2469+
expect(parseLinkAndReturn(locationUmlautUrl, 'http://other')).toEqual(undefined);
2470+
expect(parseLinkAndReturn(locationUmlautUrl, 'http://särver/pre')).toEqual('http://särver/pre/');
2471+
expect(parseLinkAndReturn(locationUmlautUrl, 'http://särver/pre/')).toEqual('http://särver/pre/');
2472+
expect(parseLinkAndReturn(locationUmlautUrl, 'http://särver/pre/otherPath')).toEqual('http://särver/pre/otherPath');
2473+
// Note: relies on the previous state!
2474+
expect(parseLinkAndReturn(locationUmlautUrl, 'someIgnoredAbsoluteHref', '#test')).toEqual('http://särver/pre/otherPath#test');
2475+
24682476
expect(parseLinkAndReturn(locationIndexUrl, 'http://server/pre')).toEqual('http://server/pre/');
24692477
expect(parseLinkAndReturn(locationIndexUrl, 'http://server/pre/')).toEqual('http://server/pre/');
24702478
expect(parseLinkAndReturn(locationIndexUrl, 'http://server/pre/otherPath')).toEqual('http://server/pre/otherPath');

0 commit comments

Comments
 (0)