Skip to content

Commit a9351dd

Browse files
committed
Check normalization before and after . cleanup
1 parent d5bfa4b commit a9351dd

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/compiler/path.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,10 +547,19 @@ namespace ts {
547547

548548
export function normalizePath(path: string): string {
549549
path = normalizeSlashes(path);
550-
path = path.replace(/\/\.\//g, "/");
550+
// Most paths don't require normalization
551551
if (!relativePathSegmentRegExp.test(path)) {
552552
return path;
553553
}
554+
// Some paths only require cleanup of `/./`
555+
const simplified = path.replace(/\/\.\//g, "/");
556+
if (simplified !== path) {
557+
path = simplified;
558+
if (!relativePathSegmentRegExp.test(path)) {
559+
return path;
560+
}
561+
}
562+
// Other paths require full normalization
554563
const normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path)));
555564
return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized;
556565
}

0 commit comments

Comments
 (0)