Skip to content

Commit 0c1b81c

Browse files
committed
Check normalization before and after . cleanup
1 parent eb5408e commit 0c1b81c

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
@@ -552,10 +552,19 @@ namespace ts {
552552

553553
export function normalizePath(path: string): string {
554554
path = normalizeSlashes(path);
555-
path = path.replace(/\/\.\//g, "/");
555+
// Most paths don't require normalization
556556
if (!relativePathSegmentRegExp.test(path)) {
557557
return path;
558558
}
559+
// Some paths only require cleanup of `/./`
560+
const simplified = path.replace(/\/\.\//g, "/");
561+
if (simplified !== path) {
562+
path = simplified;
563+
if (!relativePathSegmentRegExp.test(path)) {
564+
return path;
565+
}
566+
}
567+
// Other paths require full normalization
559568
const normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path)));
560569
return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized;
561570
}

0 commit comments

Comments
 (0)