diff --git a/favicon.svg b/favicon.svg new file mode 100644 index 0000000..6acd076 --- /dev/null +++ b/favicon.svg @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/host/serve.mjs b/host/serve.mjs index 30ba6ed..2ef5953 100644 --- a/host/serve.mjs +++ b/host/serve.mjs @@ -7,7 +7,7 @@ import { join, extname, normalize } from 'node:path'; import { fileURLToPath } from 'node:url'; const ROOT = join(fileURLToPath(import.meta.url), '..', '..'); -const MIME = { '.html': 'text/html', '.mjs': 'text/javascript', '.js': 'text/javascript', '.json': 'application/json', '.wasm': 'application/wasm' }; +const MIME = { '.html': 'text/html', '.mjs': 'text/javascript', '.js': 'text/javascript', '.json': 'application/json', '.wasm': 'application/wasm', '.svg': 'image/svg+xml' }; const ALLOWED = ['host/', 'config/', 'build/']; export function serve(port = 0) { @@ -16,7 +16,8 @@ export function serve(port = 0) { let p = decodeURIComponent(new URL(req.url, 'http://x').pathname); if (p === '/') p = '/host/web/index.html'; const rel = normalize(p).replace(/^\/+/, ''); - if (rel.includes('..') || !ALLOWED.some((a) => rel.startsWith(a)) || rel.startsWith('host/node_modules')) { res.writeHead(404).end('not found'); return; } + const isAllowed = rel === 'favicon.svg' || ALLOWED.some((a) => rel.startsWith(a)); + if (rel.includes('..') || !isAllowed || rel.startsWith('host/node_modules')) { res.writeHead(404).end('not found'); return; } const body = await readFile(join(ROOT, rel)); res.writeHead(200, { 'content-type': MIME[extname(rel)] ?? 'application/octet-stream', 'cache-control': 'no-store' }).end(body); } catch { res.writeHead(404).end('not found'); } diff --git a/host/web/index.html b/host/web/index.html index 4f2d4fb..b2b4275 100644 --- a/host/web/index.html +++ b/host/web/index.html @@ -3,6 +3,7 @@ chandra +