From c1c43495843bc85ffe4c2d598d51d35f8ac4e3dc Mon Sep 17 00:00:00 2001 From: nandithebull Date: Fri, 27 Nov 2026 16:14:41 -0800 Subject: [PATCH] Web host: give the page a moon favicon - Add favicon.svg: a crescent moon on a dark rounded tile - Link it from host/web/index.html as the page icon - serve.mjs: allow /favicon.svg through the path filter and serve it as image/svg+xml --- favicon.svg | 28 ++++++++++++++++++++++++++++ host/serve.mjs | 5 +++-- host/web/index.html | 1 + 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 favicon.svg 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 +