Simplify normalizeSlashes (#50154)

This commit is contained in:
Jake Bailey
2022-08-10 11:20:00 -07:00
committed by GitHub
parent 5fbf3b04dc
commit 7f1dc78f54
+3 -6
View File
@@ -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;
}
/**