Skip to content

Commit 6573578

Browse files
committed
handle triple slashes in url schema 'file' correctly
1 parent c8dd04b commit 6573578

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/compiler/core.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,14 @@ module ts {
459459
if (path.charCodeAt(2) === CharacterCodes.slash) return 3;
460460
return 2;
461461
}
462+
// Per RFC 1738'file' URI schema has a shape file://<host>/<path>
463+
// if <host> is omitted then it is assumed that host value is'localhost',
464+
// however slash after the omitted <host> is not removed.
465+
// file:///folder1/file1 - this is correct URI
466+
// file://folder2/file2 - this is incorrect URI
467+
if (path.lastIndexOf("file:///", 0) === 0) {
468+
return "file:///".length;
469+
}
462470
let idx = path.indexOf('://');
463471
if (idx !== -1) return idx + 3
464472
return 0;

0 commit comments

Comments
 (0)