Skip to content

fix(test): resolve the WebDAV handler path with fileURLToPath - #13196

Merged
diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.51from
huuhungn:fix/webdav-test-windows-path
Sep 11, 2026
Merged

diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.51from
huuhungn:fix/webdav-test-windows-path

Conversation

@anhtahaylove

Copy link
Copy Markdown
Contributor

Problem

All 37 tests in tests/unit/webdav-server-3485.test.ts fail on Windows:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module
  'C:\C:\...\scripts\dev\webdav-handler.mjs'

Note the doubled drive prefix. The handler path is built from URL.pathname:

const HANDLER_PATH = path.resolve(
  path.dirname(new URL(import.meta.url).pathname),
  "../../scripts/dev/webdav-handler.mjs"
);

URL.pathname returns a URL path, not an OS path. On POSIX the two happen to coincide, so this works. On Windows it yields /C:/Users/... — a leading slash before the drive letter. path.resolve does not consider that absolute, so it prepends the CWD and produces C:\C:\..., which cannot be imported.

CI runs on Linux, so this never shows up there; it only costs Windows contributors, silently, on every run.

Fix

Use fileURLToPath, which decodes a file: URL to a real OS path on every platform. (It also un-escapes percent-encoding, so paths containing spaces work — URL.pathname would leave %20 in place.) node:url was already imported here for pathToFileURL.

Verification

Same file, same machine (Windows), before and after:

pass fail
before 0 37
after 37 0

Found while auditing why a local full-suite run reports failures that CI does not. This accounts for 37 of them.

@diegosouzapw
diegosouzapw merged commit edfcb8b into diegosouzapw:release/v3.8.51 Sep 11, 2026
8 of 16 checks passed
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…ouzapw#13196)

Correct: `URL.pathname` is a URL path, so on Windows it yields `/C:/...` and `path.resolve` produces the doubled `C:\C:\` prefix. `fileURLToPath` is the right decoder and also un-escapes `%20`. All 37 WebDAV tests green here.

---

Validated in one consolidated worktree cut from `release/v3.8.51`, boarded together with the other 13 PRs of this batch — zero merge conflicts between them.

- `typecheck:core` clean
- complexity 2799 / baseline 3218 and cognitive-complexity 1265 / baseline 1437 — both under baseline
- 71 focused assertions green across the 13 test files this batch adds or touches

⚠️ base-red inherited: diegosouzapw#12732 — `Docs Gates (fast-path)`, `Merge integrity`, `No new ESLint warnings`, `Unit Tests fast-path` and `Fast Quality Gates` all reproduce on the pure `release/v3.8.51` tip (provider count 356 vs the 358 the modules define, SKILL.md drift, and `open-sse/utils/stream.ts` at 3115 > frozen 3098). None of them touch this diff.

Thanks @anhtahaylove — the root-cause write-up, the measured before/after numbers and the red-before-green proof on every one of these made the batch reviewable as a unit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants