fix: prevent numeric-only content hashes in filename templates

This commit is contained in:
Le Minh Duc 2025-09-10 15:32:06 +07:00 committed by GitHub
parent 95ce962897
commit 6f3ac96bc1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 1 deletions

View File

@ -11,6 +11,7 @@ const mime = require("mime-types");
const Chunk = require("./Chunk"); const Chunk = require("./Chunk");
const Module = require("./Module"); const Module = require("./Module");
const { parseResource } = require("./util/identifier"); const { parseResource } = require("./util/identifier");
const nonNumericOnlyHash = require("./util/nonNumericOnlyHash");
/** @typedef {import("./ChunkGraph")} ChunkGraph */ /** @typedef {import("./ChunkGraph")} ChunkGraph */
/** @typedef {import("./ChunkGraph").ModuleId} ModuleId */ /** @typedef {import("./ChunkGraph").ModuleId} ModuleId */
@ -63,7 +64,7 @@ const hashLength = (replacer, handler, assetInfo, hashName) => {
} else { } else {
const hash = replacer(match, arg, input); const hash = replacer(match, arg, input);
result = length ? hash.slice(0, length) : hash; result = length ? nonNumericOnlyHash(hash, length) : hash;
} }
if (assetInfo) { if (assetInfo) {
assetInfo.immutable = true; assetInfo.immutable = true;