From 71709be6d20f86bfb345422f949c8231ab6e04c3 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 12 May 2015 22:59:29 -0700 Subject: [PATCH 1/2] handle triple slashes in url schema 'file' correctly --- src/compiler/core.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 9fe9747fb57..803df5f9d01 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -459,6 +459,14 @@ module ts { if (path.charCodeAt(2) === CharacterCodes.slash) return 3; return 2; } + // Per RFC 1738'file' URI schema has a shape file:/// + // if is omitted then it is assumed that host value is'localhost', + // however slash after the omitted is not removed. + // file:///folder1/file1 - this is correct URI + // file://folder2/file2 - this is incorrect URI + if (path.lastIndexOf("file:///", 0) === 0) { + return "file:///".length; + } let idx = path.indexOf('://'); if (idx !== -1) return idx + 3 return 0; From 8582d80459930c1b05f26a7cadc87422b3babab0 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Fri, 15 May 2015 00:42:04 -0700 Subject: [PATCH 2/2] addressed PR feedback --- src/compiler/core.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 803df5f9d01..ef7c892be9d 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -459,16 +459,18 @@ module ts { if (path.charCodeAt(2) === CharacterCodes.slash) return 3; return 2; } - // Per RFC 1738'file' URI schema has a shape file:/// - // if is omitted then it is assumed that host value is'localhost', + // Per RFC 1738 'file' URI schema has the shape file:/// + // if is omitted then it is assumed that host value is 'localhost', // however slash after the omitted is not removed. - // file:///folder1/file1 - this is correct URI - // file://folder2/file2 - this is incorrect URI + // file:///folder1/file1 - this is a correct URI + // file://folder2/file2 - this is an incorrect URI if (path.lastIndexOf("file:///", 0) === 0) { return "file:///".length; } let idx = path.indexOf('://'); - if (idx !== -1) return idx + 3 + if (idx !== -1) { + return idx + "://".length; + } return 0; }