Skip to content

Commit 7f1dc78

Browse files
authored
Simplify normalizeSlashes (microsoft#50154)
1 parent 5fbf3b0 commit 7f1dc78

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/compiler/path.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -452,12 +452,9 @@ namespace ts {
452452
* Normalize path separators, converting `\` into `/`.
453453
*/
454454
export function normalizeSlashes(path: string): string {
455-
const index = path.indexOf("\\");
456-
if (index === -1) {
457-
return path;
458-
}
459-
backslashRegExp.lastIndex = index; // prime regex with known position
460-
return path.replace(backslashRegExp, directorySeparator);
455+
return path.indexOf("\\") !== -1
456+
? path.replace(backslashRegExp, directorySeparator)
457+
: path;
461458
}
462459

463460
/**

0 commit comments

Comments
 (0)