Skip to content

feat: allow file:// protocol prefix in absolute paths - #222

Merged
alexander-akait merged 4 commits into
mainfrom
claude/filter-errors-quadratic-sibling-dos-1tqe2l
Sep 8, 2026
Merged

feat: allow file:// protocol prefix in absolute paths#222
alexander-akait merged 4 commits into
mainfrom
claude/filter-errors-quadratic-sibling-dos-1tqe2l

Conversation

@alexander-akait

Copy link
Copy Markdown
Member

Recreates #210 by @laymonage, rebased on main, with the original commit kept as a co-author. Fixes #209.

Summary

import.meta.resolve() returns a file:// URL, so passing one to an option that takes an absolute path failed validation. The absolutePath keyword accepts an optional file:// prefix now:

- schema === /^(?:[A-Za-z]:(\\|\/)|\\\\|\/)/.test(data);
+ schema === /^(?:file:\/\/)?(?:[A-Za-z]:(\\|\/)|\\\\|\/)/.test(data);

What kind of change does this PR introduce?

A feature, plus test coverage for it.

Did you add tests for your changes?

Yes. Beyond the two cases from the original PR, every option of webpack's own schema that takes an absolute path is covered - the point being to verify the support against a real consumer rather than the fixture schema alone.

Walking webpack/schemas/WebpackOptions.json from the root and resolving $refs gives 34 reachable options that use absolutePath: true, and each one now has a test that a file:// URL validates for it:

Area Options
Top level context, recordsPath, recordsInputPath, recordsOutputPath
output output.path
cache cacheDirectory, cacheLocation, immutablePaths, managedPaths
snapshot immutablePaths, managedPaths, unmanagedPaths
module noParse and noParse[]; for both rules and defaultRules: test, include, exclude, issuer, resource, realResource, resolve.restrictions
resolve resolve.restrictions, resolveLoader.restrictions
experiments buildHttp.cacheLocation, buildHttp.lockfileLocation
Other dotenv.dir, stats.context

All 34 fail without the change to absolutePath.js and pass with it, so they are covering the behaviour rather than passing by accident.

Does this PR introduce a breaking change?

One small behaviour change, covered by its own tests: an option that takes a relative path (output.filename, output.sourceMapFilename, output.assetModuleFilename and friends, which use absolutePath: false) used to accept a file:// value, because it did not look absolute. Such a value is recognised as absolute now and is rejected for those options, which is what they mean. The changeset is a minor and calls it out.

If relevant, what needs to be documented once your changes are merged or what have you already documented?

Nothing - as in the original PR, there are no docs for the absolute path keyword.

🤖 Generated with Claude Code

https://claude.ai/code/session_013wqLmVHkAGBsWQgXknEQCK


Generated by Claude Code

alexander-akait and others added 4 commits September 8, 2026 10:42
Paths coming from `import.meta.resolve()` are `file://` URLs, so the
`absolutePath` keyword accepts an optional `file://` prefix now.

Fixes #209
Recreated from #210, rebased on `main`.

Co-Authored-By: Sage Abdullah <laymonage@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013wqLmVHkAGBsWQgXknEQCK
Walks webpack's own schema for every option reachable from the root that
uses `absolutePath: true` - 34 of them, from `output.path` and `context`
to the `module.rules` conditions and the `snapshot` path lists - and
checks a `file://` URL validates for each, so the support is verified
against the real consumer rather than the fixture schema alone.

The options that require a relative path are covered too: the prefix must
not make one of them accept an absolute path.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013wqLmVHkAGBsWQgXknEQCK
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013wqLmVHkAGBsWQgXknEQCK
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013wqLmVHkAGBsWQgXknEQCK
@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.78%. Comparing base (fc918a9) to head (863de9e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #222   +/-   ##
=======================================
  Coverage   95.78%   95.78%           
=======================================
  Files           9        9           
  Lines         949      949           
  Branches      386      387    +1     
=======================================
  Hits          909      909           
  Misses         36       36           
  Partials        4        4           
Flag Coverage Δ
integration 95.78% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@alexander-akait
alexander-akait merged commit 5c21244 into main Sep 8, 2026
33 checks passed
@alexander-akait
alexander-akait deleted the claude/filter-errors-quadratic-sibling-dos-1tqe2l branch September 8, 2026 12:33
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.

Support absolute paths with file:// protocol prefix

1 participant