From 93fee007e69a3624cf928b6c720fc9220d2df3ec Mon Sep 17 00:00:00 2001 From: anhtahaylove <37265396+anhtahaylove@users.noreply.github.com> Date: Thu, 10 Sep 2026 17:57:11 +0700 Subject: [PATCH] fix(test): resolve the WebDAV handler path with fileURLToPath --- changelog.d/fixes/webdav-test-windows-path.md | 1 + tests/unit/webdav-server-3485.test.ts | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 changelog.d/fixes/webdav-test-windows-path.md diff --git a/changelog.d/fixes/webdav-test-windows-path.md b/changelog.d/fixes/webdav-test-windows-path.md new file mode 100644 index 00000000000..2ba7400611e --- /dev/null +++ b/changelog.d/fixes/webdav-test-windows-path.md @@ -0,0 +1 @@ +- **fix(test):** resolve the WebDAV handler path with `fileURLToPath` so the suite's 37 WebDAV tests run on Windows instead of failing with a doubled `C:\C:\` drive prefix diff --git a/tests/unit/webdav-server-3485.test.ts b/tests/unit/webdav-server-3485.test.ts index f30d5824e39..291d25dc034 100644 --- a/tests/unit/webdav-server-3485.test.ts +++ b/tests/unit/webdav-server-3485.test.ts @@ -30,14 +30,19 @@ import path from "node:path"; import http from "node:http"; import { EventEmitter } from "node:events"; import { createCipheriv, randomBytes, scryptSync } from "node:crypto"; -import { pathToFileURL } from "node:url"; +import { fileURLToPath, pathToFileURL } from "node:url"; // ───────────────────────────────────────────────────────────────────────────── // Helpers // ───────────────────────────────────────────────────────────────────────────── +// `URL.pathname` is a URL path, not an OS path: on Windows it yields +// "/C:/..." — a leading slash before the drive letter. `path.resolve` does not +// treat that as absolute, so it prepends the CWD and produces "C:\C:\...", +// which fails to import. `fileURLToPath` decodes to a real OS path on every +// platform (it also un-escapes %20 in paths containing spaces). const HANDLER_PATH = path.resolve( - path.dirname(new URL(import.meta.url).pathname), + path.dirname(fileURLToPath(import.meta.url)), "../../scripts/dev/webdav-handler.mjs" );