fix(assets): leeres HB_ASSET_TYPES als nicht gesetzt behandeln (#32)

Die Compose-Vorlage setzt HB_ASSET_TYPES="", was den Start abbrechen liess.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
dev-bot BotandClaude Sonnet 5.5 committed 2026-11-26 11:40:05 +00:00
1 parent 1fe99698fb
commit 75548d39f3
2 files changed
+6 -1

No files matched your search

+4
View File
@@ -41,6 +41,10 @@ describe('Konfiguration', ()=>{
expect(readAssetsConfig({ HB_ASSET_MAX_BYTES: '1000', HB_ASSET_MAX_BYTES_PER_BREW: '5000', HB_ASSET_TYPES: 'png, jpg,jpeg' }))
.toMatchObject({ maxBytes: 1000, maxBytesPerBrew: 5000, types: ['png', 'jpeg'] });
});
test('Leeres HB_ASSET_TYPES (Compose-Vorlage setzt "") gilt als nicht gesetzt', ()=>{
expect(readAssetsConfig({ HB_ASSET_TYPES: '' }).types).toEqual(['png', 'jpeg', 'gif', 'webp']);
expect(readAssetsConfig({ HB_ASSET_TYPES: ' ' }).types).toEqual(['png', 'jpeg', 'gif', 'webp']);
});
test('SVG und Unsinn sind Startfehler', ()=>{
expect(()=>readAssetsConfig({ HB_ASSET_TYPES: 'png,svg' })).toThrow(/svg/i);
expect(()=>readAssetsConfig({ HB_ASSET_TYPES: ',' })).toThrow(/leer/);
+2 -1
View File
@@ -32,7 +32,8 @@ export const readAssetsConfig = (env = process.env, { gitEnabled = true, driver
if(driver === 'mongo' && maxBytes > MONGO_MAX_ASSET_BYTES)
throw new Error('HB_ASSET_MAX_BYTES darf mit MongoDB höchstens 15 MiB (15728640) betragen (Dokumentlimit 16 MiB).');
const names = String(env.HB_ASSET_TYPES ?? 'png,jpeg,gif,webp').split(',').map((s)=>s.trim().toLowerCase().replace(/^jpg$/, 'jpeg')).filter(Boolean);
const rawTypes = String(env.HB_ASSET_TYPES ?? '').trim() || 'png,jpeg,gif,webp';
const names = rawTypes.split(',').map((s)=>s.trim().toLowerCase().replace(/^jpg$/, 'jpeg')).filter(Boolean);
const unknown = names.filter((n)=>!KNOWN_TYPES[n]);
if(unknown.length) throw new Error(`HB_ASSET_TYPES enthält nicht unterstützte Typen: ${unknown.join(', ')} (erlaubt: ${Object.keys(KNOWN_TYPES).join(', ')}; SVG ist ausgeschlossen)`);
if(!names.length) throw new Error('HB_ASSET_TYPES darf nicht leer sein');