Skip to content

Commit ec51f12

Browse files
committed
Simplify normalizeSlashes
1 parent 040c121 commit ec51f12

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

‎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)