nginx: tipo MIME per jpg e mp4 (la foto del palio e i video arrivavano come application/octet-stream), cache lunga anche per loro e per il favicon; test che ogni estensione servita abbia il suo tipo
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A1dxvtsZx8NE9fwjXUNDBr
This commit is contained in:
@@ -619,6 +619,19 @@ test('ogni cartella di assets usata dal gioco finisce nell\'immagine Docker', as
|
||||
for (const t of Object.values(story.tutorials)) for (const f of [t.src, t.poster]) assert.ok(existsSync(new URL(f, root)), f);
|
||||
});
|
||||
|
||||
// La foto del palio e i video arrivavano al browser come application/octet-stream (26 ottobre): ogni estensione
|
||||
// servita deve avere il suo tipo in nginx.conf, sennò nginx (con i soli tipi dichiarati) non sa cos'è.
|
||||
test('ogni estensione dei file serviti ha il suo tipo MIME in nginx.conf', async () => {
|
||||
const { readdirSync } = await import('node:fs');
|
||||
const root = new URL('../', import.meta.url);
|
||||
const types = readFileSync(new URL('nginx.conf', root), 'utf8').match(/types \{([^}]*)\}/)[1];
|
||||
const known = new Set(types.split(';').flatMap(l => l.trim().split(/\s+/).slice(1)));
|
||||
const dirs = readFileSync(new URL('Dockerfile', root), 'utf8').match(/^COPY (assets\/\S+|src)\s/gm).map(l => l.split(' ')[1]);
|
||||
const ext = new Set(['html', 'css']);
|
||||
for (const d of dirs) for (const f of readdirSync(new URL(d + '/', root), { recursive: true })) if (/\.\w+$/.test(f)) ext.add(f.split('.').pop());
|
||||
assert.deepEqual([...ext].filter(e => !known.has(e) && e !== 'txt').sort(), [], 'estensioni senza tipo in nginx.conf');
|
||||
});
|
||||
|
||||
test('i file che il Docker copia sono leggibili da tutti (nginx gira con un altro utente)', async () => {
|
||||
const { readdirSync, statSync } = await import('node:fs');
|
||||
const root = new URL('../', import.meta.url);
|
||||
|
||||
Reference in New Issue
Block a user