Skip to content

fix(@angular/build): ensure import map integrity keys are valid URL-like specifiers#33618

Merged
alan-agius4 merged 1 commit into
angular:mainfrom
alan-agius4:fix-sri-importmap-keys
Jul 21, 2026
Merged

fix(@angular/build): ensure import map integrity keys are valid URL-like specifiers#33618
alan-agius4 merged 1 commit into
angular:mainfrom
alan-agius4:fix-sri-importmap-keys

Conversation

@alan-agius4

Copy link
Copy Markdown
Collaborator

In import maps, the keys for the integrity map must be valid URL-like specifiers (either absolute URLs, or relative URLs starting with /, ./, or ../). If a key is a bare filename like chunk-SYbG1sRo.js, the browser ignores it with a warning.

We now prepend ./ to relative paths in the integrity map keys if they do not start with a slash, dot-slash, or protocol, resolving browser warning issues when subresource integrity is enabled for dynamically loaded chunks.

Fixes #33617

@alan-agius4 alan-agius4 added the target: patch This PR is targeted for the next patch release label Jul 21, 2026
@alan-agius4
alan-agius4 requested a review from clydin July 21, 2026 09:32

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request ensures that subresource integrity (SRI) importmap keys are formatted as valid URL-like specifiers by prepending ./ to relative paths that do not start with a dot or slash. While the implementation and accompanying tests are solid, the regular expression used to identify resolvable URLs is too permissive and will incorrectly match filenames starting with 'http' or 'https' (e.g., 'http-client.js'). It is recommended to update the regex to require '://' after the protocol to prevent this issue.

Comment thread packages/angular/build/src/utils/index-file/augment-index-html.ts Outdated
@alan-agius4
alan-agius4 force-pushed the fix-sri-importmap-keys branch from 46e142c to 7b1b8df Compare July 21, 2026 09:33
@alan-agius4 alan-agius4 added the action: review The PR is still awaiting reviews from at least one requested reviewer label Jul 21, 2026
…ike specifiers

In import maps, the keys for the integrity map must be valid URL-like
specifiers (either absolute URLs, or relative URLs starting with /, ./, or ../).
If a key is a bare filename like chunk-SYbG1sRo.js, the browser ignores it with a warning.

We now prepend ./ to relative paths in the integrity map keys if they do not
start with a slash, dot-slash, or protocol, resolving browser warning issues
when subresource integrity is enabled for dynamically loaded chunks.

Fixes angular#33617
@alan-agius4
alan-agius4 force-pushed the fix-sri-importmap-keys branch from 7b1b8df to 2b48db4 Compare July 21, 2026 09:38
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jul 21, 2026
@alan-agius4
alan-agius4 merged commit 21b8fc0 into angular:main Jul 21, 2026
40 checks passed
@alan-agius4
alan-agius4 deleted the fix-sri-importmap-keys branch July 21, 2026 16:19
@alan-agius4

Copy link
Copy Markdown
Collaborator Author

This PR was merged into the repository. The changes were merged into the following branches:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Output bundle import map integrity key warning in browser

2 participants