Skip to content

Conversation

@LingyuCoder
Copy link
Contributor

@LingyuCoder LingyuCoder commented Nov 21, 2025

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

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings November 21, 2025 10:24
@netlify
Copy link

netlify bot commented Nov 21, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit d1fe4f0
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/6923159734decd0009f09475

@github-actions github-actions bot added release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack. labels Nov 21, 2025
@LingyuCoder LingyuCoder changed the title fix: should match relative protocol of public path and tag src in SRI plugin fix: should match protocol-relative url of public path and tag src in SRI plugin Nov 21, 2025
Copilot finished reviewing on behalf of LingyuCoder November 21, 2025 10:29
Copy link
Contributor

Copilot AI left a 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 publicPath to protocol-relative format for comparison
  • Applies SRI integrity attributes to resources that match the publicPath regardless 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.

Copy link
Contributor Author

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@github-actions
Copy link
Contributor

github-actions bot commented Nov 21, 2025

📦 Binary Size-limit

Comparing d1fe4f0 to feat: support SRI with experiments.css and CssExtractRspackPlugin (#12239) by harpsealjs

❌ Size increased by 7.00KB from 47.63MB to 47.64MB (⬆️0.01%)

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 21, 2025

CodSpeed Performance Report

Merging #12265 will not alter performance

Comparing fix/sri-remote-url-relative-protocol (d1fe4f0) with main (ca1a20f)

Summary

✅ 17 untouched

@CLAassistant
Copy link

CLAassistant commented Nov 23, 2025

CLA assistant check
All committers have signed the CLA.

@LingyuCoder LingyuCoder force-pushed the fix/sri-remote-url-relative-protocol branch from 0b81102 to d1fe4f0 Compare November 23, 2025 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants