From e9c4c9d4bacfacc41aef57f2f8048160e290a2fd Mon Sep 17 00:00:00 2001 From: Ola Hungerford Date: Thu, 19 Jun 2025 21:29:31 -0700 Subject: [PATCH] Handle unc path --- src/filesystem/path-utils.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/filesystem/path-utils.ts b/src/filesystem/path-utils.ts index de0417ec..aca7f061 100644 --- a/src/filesystem/path-utils.ts +++ b/src/filesystem/path-utils.ts @@ -55,8 +55,13 @@ export function normalizePath(p: string): string { // Handle double backslashes, preserving leading UNC \\ if (p.startsWith('\\\\')) { - // For UNC paths, normalize double backslashes *after* the leading marker - const restOfPath = p.substring(2).replace(/\\\\/g, '\\'); + // For UNC paths, first normalize any excessive leading backslashes to exactly \\ + // Then normalize double backslashes in the rest of the path + let uncPath = p; + // Replace multiple leading backslashes with exactly two + uncPath = uncPath.replace(/^\\{2,}/, '\\\\'); + // Now normalize any remaining double backslashes in the rest of the path + const restOfPath = uncPath.substring(2).replace(/\\\\/g, '\\'); p = '\\\\' + restOfPath; } else { // For non-UNC paths, normalize all double backslashes