Skip to content

Commit e9c4c9d

Browse files
committed
Handle unc path
1 parent 9dd94fd commit e9c4c9d

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/filesystem/path-utils.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,13 @@ export function normalizePath(p: string): string {
5555

5656
// Handle double backslashes, preserving leading UNC \\
5757
if (p.startsWith('\\\\')) {
58-
// For UNC paths, normalize double backslashes *after* the leading marker
59-
const restOfPath = p.substring(2).replace(/\\\\/g, '\\');
58+
// For UNC paths, first normalize any excessive leading backslashes to exactly \\
59+
// Then normalize double backslashes in the rest of the path
60+
let uncPath = p;
61+
// Replace multiple leading backslashes with exactly two
62+
uncPath = uncPath.replace(/^\\{2,}/, '\\\\');
63+
// Now normalize any remaining double backslashes in the rest of the path
64+
const restOfPath = uncPath.substring(2).replace(/\\\\/g, '\\');
6065
p = '\\\\' + restOfPath;
6166
} else {
6267
// For non-UNC paths, normalize all double backslashes

0 commit comments

Comments
 (0)