Skip to content

Commit 33abdad

Browse files
committed
Fix #8470: use ts.normalizePath before checking filename idenity
1 parent 674e84b commit 33abdad

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/services/services.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1921,7 +1921,7 @@ namespace ts {
19211921

19221922
// Create a compilerHost object to allow the compiler to read and write files
19231923
const compilerHost: CompilerHost = {
1924-
getSourceFile: (fileName, target) => fileName === normalizeSlashes(inputFileName) ? sourceFile : undefined,
1924+
getSourceFile: (fileName, target) => fileName === normalizePath(inputFileName) ? sourceFile : undefined,
19251925
writeFile: (name, text, writeByteOrderMark) => {
19261926
if (fileExtensionIs(name, ".map")) {
19271927
Debug.assert(sourceMapText === undefined, `Unexpected multiple source map outputs for the file '${name}'`);

tests/cases/unittests/transpile.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ var x = 0;`,
277277
it("Supports backslashes in file name", () => {
278278
test("var x", { expectedOutput: `"use strict";\r\nvar x;\r\n`, options: { fileName: "a\\b.ts" }});
279279
});
280-
280+
281281
it("transpile file as 'tsx' if 'jsx' is specified", () => {
282282
let input = `var x = <div/>`;
283283
let output = `"use strict";\nvar x = React.createElement("div", null);\n`;
@@ -286,6 +286,7 @@ var x = 0;`,
286286
options: { compilerOptions: { jsx: JsxEmit.React, newLine: NewLineKind.LineFeed } }
287287
})
288288
});
289+
289290
it("transpile .js files", () => {
290291
const input = "const a = 10;";
291292
const output = `"use strict";\nvar a = 10;\n`;
@@ -295,5 +296,9 @@ var x = 0;`,
295296
expectedDiagnosticCodes: []
296297
});
297298
})
299+
300+
it("Supports urls in file name", () => {
301+
test("var x", { expectedOutput: `"use strict";\r\nvar x;\r\n`, options: { fileName: "http://somewhere/directory//directory2/file.ts" } });
302+
});
298303
});
299304
}

0 commit comments

Comments
 (0)