Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 82b44da

Browse filesBrowse files
pierreboissinotsmnandre
authored andcommitted
[AssetMapper] Add integrity hash to modulepreload
1 parent e8c0c50 commit 82b44da
Copy full SHA for 82b44da

File tree

1 file changed

+7
-4
lines changed
Filter options

1 file changed

+7
-4
lines changed

‎src/Symfony/Component/AssetMapper/ImportMap/ImportMapRenderer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/AssetMapper/ImportMap/ImportMapRenderer.php
+7-4Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function render(string|array $entryPoint, array $attributes = []): string
7878
$integrityMap[$path] = $integrity;
7979
}
8080
if ($preload) {
81-
$modulePreloads[] = $path;
81+
$modulePreloads[] = ['path' => $path, 'integrity' => $integrity];
8282
}
8383
} elseif ($preload) {
8484
$cssLinks[] = $path;
@@ -142,10 +142,13 @@ public function render(string|array $entryPoint, array $attributes = []): string
142142
HTML;
143143
}
144144

145-
foreach ($modulePreloads as $url) {
146-
$url = $this->escapeAttributeValue($url);
145+
foreach ($modulePreloads as $modulePreload) {
146+
$url = $this->escapeAttributeValue($modulePreload['path']);
147+
if ($integrity = $modulePreload['integrity']) {
148+
$integrity = " integrity=\"$integrity\"";
149+
}
147150

148-
$output .= "\n<link rel=\"modulepreload\" href=\"$url\">";
151+
$output .= "\n<link rel=\"modulepreload\" href=\"$url\"$integrity>";
149152
}
150153

151154
if (\count($entryPoint) > 0) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.