fix: update-sri.ts handle unquoted attributes after HTML minification#2434
Merged
Conversation
The coderaiser/minify package strips quotes from HTML attributes, turning integrity="sha384-..." into integrity=sha384-.... The update-sri.ts regexes only matched quoted forms, causing the "No HTML files reference X with an integrity attribute" error in deploy-s3.yml. Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/98ba31d4-d346-4e76-9b20-cfc812698ef9 Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
pethers
May 12, 2026 15:02
View session
Contributor
🏷️ Automatic Labeling SummaryThis PR has been automatically labeled based on the files changed and PR metadata. Applied Labels: testing,refactor,size-s Label Categories
For more information, see |
Contributor
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the deploy-time SRI rewriter to correctly detect and update integrity=sha384-... attributes after HTML minification removes quotes, preventing false “absent integrity” failures during deploy.
Changes:
- Updated
update-sri.tsregexes to match both quoted and unquotedhref/integrityattribute values. - Added a regression test covering unquoted attributes as produced by
coderaiser/minifyv15.x.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| scripts/update-sri.ts | Makes SRI matching resilient to minified HTML by accepting unquoted href/integrity attribute values. |
| tests/css-purge-and-minify.test.ts | Adds a fixture ensuring updateSri() updates integrity hashes when attributes are unquoted. |
Comment on lines
+108
to
+111
| // Match href=["']?…<cssBasename>…["']? … integrity=["']?sha384-…["']? | ||
| // inside a <link> tag. The HTML minifier (coderaiser/minify) strips | ||
| // quotes from attributes whose values contain no special characters, | ||
| // so we must handle both quoted and unquoted forms. |
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.
coderaiser/minifyv15.x strips double quotes from HTML attributes, turningintegrity="sha384-..."intointegrity=sha384-.... Theupdate-sri.tsregexes only matched quoted forms, so every HTML file was classified as "absent" and the script errored out during S3 deploy.Changes
scripts/update-sri.ts— Made quotes optional ("?) in bothlinkTagReandHASH_SNIFF_REregexes to match both pre- and post-minification HTMLtests/css-purge-and-minify.test.ts— Added test case exercising unquoted attributes as produced by the minifier