Added calculators

This commit is contained in:
Codex
2026-03-07 11:56:16 +00:00
parent 436a15df2b
commit d2519238ce
3 changed files with 147 additions and 3 deletions

View File

@@ -0,0 +1,31 @@
import path from 'node:path';
import type { Handle } from '@sveltejs/kit';
const MIME_TYPES: Record<string, string> = {
'.js': 'application/javascript; charset=utf-8',
'.mjs': 'application/javascript; charset=utf-8',
'.css': 'text/css; charset=utf-8',
'.json': 'application/json; charset=utf-8',
'.svg': 'image/svg+xml; charset=utf-8',
'.woff2': 'font/woff2',
'.woff': 'font/woff',
'.ttf': 'font/ttf',
'.otf': 'font/otf'
};
export const handle: Handle = async ({ event, resolve }) => {
const response = await resolve(event);
if (event.url.pathname.startsWith('/_app/')) {
const existing = response.headers.get('content-type');
const hasValidHeader = existing && existing.trim().length > 0;
if (!hasValidHeader) {
const extension = path.extname(event.url.pathname).toLowerCase();
const mime = extension && MIME_TYPES[extension];
if (mime) {
response.headers.set('content-type', mime);
}
}
}
return response;
};