fix: sync the absolutePath file URL prefix with schema-utils - #50
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
precompile-schemashoists its own copy of theabsolutePathregexp, with a comment saying it must stay in sync with theschema-utilskeyword 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 rejectfile:/directoryandFILE:///directorythat the real keyword accepts.The lookahead leaves the first slash to the path part, so
file:directoryandfile: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 testisyarn lint). Verified instead by running the patched generator over webpack's real schemas: all 12.check.jsfiles regenerate with the new regexp, and the regeneratedWebpackOptions.check.jsacceptsfile:///directory,file:/directory,FILE:///directoryand/directorywhile rejectingfile:directory,file:C:/directoryanddirectory— the same seven-case result as schema-utils after #226.lockfile-lint,tscand Prettier over the changed file are clean. (Prettier already reportsgenerate-types/index.json 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