Skip to content

fix: sync the absolutePath file URL prefix with schema-utils - #50

Merged
alexander-akait merged 1 commit into
mainfrom
fix/absolute-path-file-url-slashes
Sep 13, 2026
Merged

fix: sync the absolutePath file URL prefix with schema-utils#50
alexander-akait merged 1 commit into
mainfrom
fix/absolute-path-file-url-slashes

Conversation

@alexander-akait

Copy link
Copy Markdown
Member

Summary

precompile-schemas hoists its own copy of the absolutePath regexp, with a comment saying it must stay in sync with the schema-utils keyword because the pre-compiled schema has to accept exactly what the real one accepts. webpack/schema-utils#226 just moved that keyword to match Node's URL parser — any number of slashes after the scheme, matched case-insensitively — so the copy here is now out of sync and a pre-compiled schema would reject file:/directory and FILE:///directory that the real keyword accepts.

-const absolutePathRegExp = /^(?:file:\/\/)?(?:[A-Za-z]:[\\/]|\\\\|\/)/;
+const absolutePathRegExp = /^(?:file:(?=\/))?(?:[A-Za-z]:[\\/]|\\\\|\/)/i;

The lookahead leaves the first slash to the path part, so file:directory and file:C:/directory — a scheme with nothing absolute after it — stay rejected, exactly as in schema-utils.

What kind of change does this PR introduce?

fix.

Did you add tests for your changes?

No — this repository has no test suite (yarn test is yarn lint). Verified instead by running the patched generator over webpack's real schemas: all 12 .check.js files regenerate with the new regexp, and the regenerated WebpackOptions.check.js accepts file:///directory, file:/directory, FILE:///directory and /directory while rejecting file:directory, file:C:/directory and directory — the same seven-case result as schema-utils after #226. lockfile-lint, tsc and Prettier over the changed file are clean. (Prettier already reports generate-types/index.js on an unmodified checkout; that is pre-existing and left alone.)

Does this PR introduce a breaking change?

No — every value accepted before is still accepted; only rejected ones become valid.

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

n/a

Use of AI

Written with Claude Code. It found the divergence while aligning the same regexp in enhanced-resolve and schema-utils, made the change, regenerated webpack's validators with the patched generator to confirm the emitted output and its accept/reject set, and ran the lint stages locally; every claim above was verified by running it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TmnzpSwSysywhmNw9p3uT5


Generated by Claude Code

The hoisted copy wanted exactly two slashes and a lower-case scheme, so a
pre-compiled schema rejected `file:/abs` and `FILE:///abs` where the real
keyword now takes both. The lookahead leaves the first slash to the path
part, keeping a scheme with nothing absolute after it rejected.
@alexander-akait
alexander-akait merged commit 64e019d into main Sep 13, 2026
9 checks passed
@alexander-akait
alexander-akait deleted the fix/absolute-path-file-url-slashes branch September 13, 2026 12:24
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.

1 participant