-
-
Notifications
You must be signed in to change notification settings - Fork 736
fix: should match protocol-relative url of public path and tag src in SRI plugin #12265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for rspack canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes the Subresource Integrity (SRI) plugin to properly handle protocol-relative URLs (URLs starting with //) and ensure they're correctly matched against the configured publicPath regardless of whether one uses an explicit protocol (http: or https:) and the other doesn't.
Key Changes:
- Normalizes both tag source URLs and
publicPathto protocol-relative format for comparison - Applies SRI integrity attributes to resources that match the
publicPathregardless of protocol differences - Adds comprehensive test coverage for various protocol matching scenarios
Reviewed Changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
packages/rspack/src/builtin-plugin/SubresourceIntegrityPlugin.ts |
Updated TypeScript implementation to normalize URLs by removing protocols before comparison and then restoring the publicPath protocol |
crates/rspack_plugin_sri/src/html.rs |
Updated Rust implementation with equivalent protocol normalization logic |
crates/rspack_plugin_sri/Cargo.toml |
Added once_cell dependency for lazy static regex initialization |
Cargo.lock |
Updated lock file with once_cell dependency |
tests/rspack-test/configCases/sri/remote-src-protocol/rspack.config.js |
Added comprehensive test cases covering all combinations of protocol-relative and explicit protocol URLs |
tests/rspack-test/configCases/sri/remote-src-protocol/test.config.js |
Added test configuration |
tests/rspack-test/configCases/sri/remote-src-protocol/index.js |
Added test entry point with dynamic import |
tests/rspack-test/configCases/sri/remote-src-protocol/chunk.js |
Added empty chunk file for dynamic import testing |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check this test case. Does this meet your requirements? @nanianlisao
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
📦 Binary Size-limit
❌ Size increased by 6.88KB from 47.63MB to 47.64MB (⬆️0.01%) |
CodSpeed Performance ReportMerging #12265 will degrade performances by 20.41%Comparing Summary
Benchmarks breakdown
|
Summary
Support protocol-relative url when match public path and tag src. Both the public path and tag src can be protocol-relative url. If they are matched, the SRI integrity hash should be found and add to the tag.
Originally posted by @nanianlisao in #12262 (comment)
Related links
Checklist