diff --git a/packages/core/src/plugins/asset.ts b/packages/core/src/plugins/asset.ts index 58c4e1c97a..5e97275bea 100644 --- a/packages/core/src/plugins/asset.ts +++ b/packages/core/src/plugins/asset.ts @@ -70,13 +70,17 @@ const chainStaticAssetRule = ({ }; export function getRegExpForExts(exts: string[]): RegExp { - const matcher = exts - .map((ext) => ext.trim()) - .map((ext) => (ext.startsWith('.') ? ext.slice(1) : ext)) - .join('|'); + const normalizedExts: string[] = []; + + for (const ext of exts) { + const trimmed = ext.trim(); + normalizedExts.push(trimmed.startsWith('.') ? trimmed.slice(1) : trimmed); + } + + const matcher = normalizedExts.join('|'); return new RegExp( - exts.length === 1 ? `\\.${matcher}$` : `\\.(?:${matcher})$`, + normalizedExts.length === 1 ? `\\.${matcher}$` : `\\.(?:${matcher})$`, 'i', ); }