From a749069bbf014f95d41bcb72e9349d8978683e5f Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 30 Jun 2026 14:22:53 +0100 Subject: [PATCH] Revert "path: fix win32 normalize false-positive on reserved names" This reverts commit b0a4f162df5ebb4a41fb6c8e15e8bdbe0d695a3d as it was merged without green Jenkins CI and subsequent builds are broken. Refs: https://github.com/nodejs/node/pull/64159 Signed-off-by: Anna Henningsen --- lib/path.js | 2 +- test/parallel/test-path-normalize.js | 11 ----------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/lib/path.js b/lib/path.js index 253f5dc6165804..63b037cddfb986 100644 --- a/lib/path.js +++ b/lib/path.js @@ -471,7 +471,7 @@ const win32 = { } while ((index = StringPrototypeIndexOf(path, ':', index + 1)) !== -1); } const colonIndex = StringPrototypeIndexOf(path, ':'); - if (colonIndex !== -1 && isWindowsReservedName(path, colonIndex)) { + if (isWindowsReservedName(path, colonIndex)) { return `.\\${device ?? ''}${tail}`; } if (device === undefined) { diff --git a/test/parallel/test-path-normalize.js b/test/parallel/test-path-normalize.js index c0e7309602b60b..8b537676dbf45d 100644 --- a/test/parallel/test-path-normalize.js +++ b/test/parallel/test-path-normalize.js @@ -69,17 +69,6 @@ assert.strictEqual(path.win32.normalize('//server/share/dir/../../../?/D:/file') assert.strictEqual(path.win32.normalize('//server/goodshare/../badshare/file'), '\\\\server\\goodshare\\badshare\\file'); -// A path is only a Windows reserved device name when the reserved name is -// followed by a colon. A name that merely starts with a reserved name (and has -// no colon) must be left untouched and not be prefixed with `.\`. -assert.strictEqual(path.win32.normalize('CONx'), 'CONx'); -assert.strictEqual(path.win32.normalize('NULs'), 'NULs'); -assert.strictEqual(path.win32.normalize('LPT1x'), 'LPT1x'); -assert.strictEqual(path.win32.normalize('PRNzzz'), 'PRNzzz'); -assert.strictEqual(path.win32.normalize('CON'), 'CON'); -// With a trailing colon the reserved-name handling still applies. -assert.strictEqual(path.win32.normalize('CON:'), '.\\CON:.'); - assert.strictEqual(path.posix.normalize('./fixtures///b/../b/c.js'), 'fixtures/b/c.js'); assert.strictEqual(path.posix.normalize('/foo/../../../bar'), '/bar');