From 7f1dc78f542b95883d66dbd025c13f67cc267668 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 10 Aug 2022 14:20:00 -0400 Subject: [PATCH] Simplify normalizeSlashes (#50154) --- src/compiler/path.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/compiler/path.ts b/src/compiler/path.ts index ebc837feb33..86bafd8f785 100644 --- a/src/compiler/path.ts +++ b/src/compiler/path.ts @@ -452,12 +452,9 @@ namespace ts { * Normalize path separators, converting `\` into `/`. */ export function normalizeSlashes(path: string): string { - const index = path.indexOf("\\"); - if (index === -1) { - return path; - } - backslashRegExp.lastIndex = index; // prime regex with known position - return path.replace(backslashRegExp, directorySeparator); + return path.indexOf("\\") !== -1 + ? path.replace(backslashRegExp, directorySeparator) + : path; } /**