mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-26 00:36:29 -05:00
Simplify normalizeSlashes (#50154)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user