mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Simplify normalizeSlashes (#50154)
This commit is contained in:
parent
5fbf3b04dc
commit
7f1dc78f54
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user