From 85afa775554e60bd1ffc82493da5ba6d2aee0f15 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 23 Dec 2024 22:44:29 +0100 Subject: [PATCH] fixup! url: use resolved path to convert UNC paths to URL --- lib/internal/url.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/internal/url.js b/lib/internal/url.js index 6b565e1bfad2c9..c043b0f4534e17 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -1512,8 +1512,11 @@ function fileURLToPath(path, options = kEmptyObject) { function pathToFileURL(filepath, options = kEmptyObject) { const windows = options?.windows ?? isWindows; - let resolved = windows ? path.win32.resolve(filepath) : path.posix.resolve(filepath); - if (windows && StringPrototypeStartsWith(resolved, '\\\\')) { + const isUNC = windows && StringPrototypeStartsWith(filepath, '\\\\'); + let resolved = isUNC ? + filepath : + (windows ? path.win32.resolve(filepath) : path.posix.resolve(filepath)); + if (isUNC || windows && StringPrototypeStartsWith(resolved, '\\\\')) { // UNC path format: \\server\share\resource // Handle extended UNC path and standard UNC path // "\\?\UNC\" path prefix should be ignored.