Skip to content
Merged
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
14 changes: 9 additions & 5 deletions packages/core/src/plugins/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
);
}
Expand Down
Loading