Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 5.0.1

* #1349 Fix issue between `Encore.enableIntegrityHashes()` and filenames with a query-string (@Kocal)

## 5.0.0

This is a new major version that contains several backwards-compatibility breaks.
Expand Down
7 changes: 5 additions & 2 deletions lib/webpack/entry-points-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,12 @@ class EntryPointsPlugin {
for (const entryName in manifest.entrypoints) {
for (const fileType in manifest.entrypoints[entryName]) {
for (const asset of manifest.entrypoints[entryName][fileType]) {
if (asset in manifest.integrity) {
continue;
}

// Drop query string if any
const assetNormalized = asset.includes('?') ? asset.split('?')[0] : asset;

if (assetNormalized in manifest.integrity) {
continue;
}
Expand All @@ -118,7 +121,7 @@ class EntryPointsPlugin {
fileHashes.push(`${algorithm}-${hash.digest('base64')}`);
}

manifest.integrity[assetNormalized] = fileHashes.join(' ');
manifest.integrity[asset] = fileHashes.join(' ');
}
}
}
Expand Down
13 changes: 8 additions & 5 deletions test/functional.js
Original file line number Diff line number Diff line change
Expand Up @@ -3138,11 +3138,14 @@ module.exports = {

testSetup.runWebpack(config, (webpackAssert) => {
const integrityData = getIntegrityData(config);
const expectedFilesWithHashes = [
'/build/runtime.js',
'/build/main.js',
'/build/styles.css',
];
const expectedFilesWithHashes = Object.keys(integrityData).filter(file => {
if (!/\?v=[a-z0-9]{16}$/.test(file)) {
return false;
}
return file.startsWith('/build/runtime.js?v=')
|| file.startsWith('/build/main.js?v=')
|| file.startsWith('/build/styles.css?v=');
});

expectedFilesWithHashes.forEach((file) => {
expect(integrityData[file]).to.contain('sha384-');
Expand Down