From ec4a1c89eba5bb1f57f7a2d6d7d06b9697017820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=BCseyin=20A=C3=A7acak?= <110401522+huseyinacacak-janea@users.noreply.github.com> Date: Mon, 13 May 2024 16:43:16 +0300 Subject: [PATCH] path: fix toNamespacedPath on Windows PR-URL: https://github.com/nodejs/node/pull/52915 Fixes: https://github.com/nodejs/node/issues/30224 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Luigi Pinca --- lib/path.js | 2 +- test/parallel/test-path-makelong.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/path.js b/lib/path.js index 1a2b3e38eca03f..71bc231bd6df94 100644 --- a/lib/path.js +++ b/lib/path.js @@ -647,7 +647,7 @@ const win32 = { return `\\\\?\\${resolvedPath}`; } - return path; + return resolvedPath; }, /** diff --git a/test/parallel/test-path-makelong.js b/test/parallel/test-path-makelong.js index b0a4ebc6b30b62..7a4783953c8fde 100644 --- a/test/parallel/test-path-makelong.js +++ b/test/parallel/test-path-makelong.js @@ -79,7 +79,8 @@ assert.strictEqual(path.win32.toNamespacedPath('\\\\foo\\bar'), '\\\\?\\UNC\\foo\\bar\\'); assert.strictEqual(path.win32.toNamespacedPath('//foo//bar'), '\\\\?\\UNC\\foo\\bar\\'); -assert.strictEqual(path.win32.toNamespacedPath('\\\\?\\foo'), '\\\\?\\foo'); +assert.strictEqual(path.win32.toNamespacedPath('\\\\?\\foo'), '\\\\?\\foo\\'); +assert.strictEqual(path.win32.toNamespacedPath('\\\\?\\c:\\Windows/System'), '\\\\?\\c:\\Windows\\System'); assert.strictEqual(path.win32.toNamespacedPath(null), null); assert.strictEqual(path.win32.toNamespacedPath(true), true); assert.strictEqual(path.win32.toNamespacedPath(1), 1);