Skip to content

Commit 7e23c72

Browse files
committed
Fix integrity hashes with query string, use the original assets name in "integrity" map
1 parent ce54d41 commit 7e23c72

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## 5.0.1
4+
5+
* #1349 Fix issue between `Encore.enableIntegrityHashes()` and filenames with a query-string (@Kocal)
6+
37
## 5.0.0
48

59
This is a new major version that contains several backwards-compatibility breaks.

lib/webpack/entry-points-plugin.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,12 @@ class EntryPointsPlugin {
9595
for (const entryName in manifest.entrypoints) {
9696
for (const fileType in manifest.entrypoints[entryName]) {
9797
for (const asset of manifest.entrypoints[entryName][fileType]) {
98+
if (asset in manifest.integrity) {
99+
continue;
100+
}
101+
98102
// Drop query string if any
99103
const assetNormalized = asset.includes('?') ? asset.split('?')[0] : asset;
100-
101104
if (assetNormalized in manifest.integrity) {
102105
continue;
103106
}
@@ -118,7 +121,7 @@ class EntryPointsPlugin {
118121
fileHashes.push(`${algorithm}-${hash.digest('base64')}`);
119122
}
120123

121-
manifest.integrity[assetNormalized] = fileHashes.join(' ');
124+
manifest.integrity[asset] = fileHashes.join(' ');
122125
}
123126
}
124127
}

test/functional.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3139,9 +3139,9 @@ module.exports = {
31393139
testSetup.runWebpack(config, (webpackAssert) => {
31403140
const integrityData = getIntegrityData(config);
31413141
const expectedFilesWithHashes = [
3142-
'/build/runtime.js',
3143-
'/build/main.js',
3144-
'/build/styles.css',
3142+
'/build/runtime.js?v=20a50360a1782493',
3143+
'/build/main.js?v=916b1472d0bc8258',
3144+
'/build/styles.css?v=4f61639dd8b6c51f',
31453145
];
31463146

31473147
expectedFilesWithHashes.forEach((file) => {

0 commit comments

Comments
 (0)