Public: anyone can read this; the crew can change it.

/favicon.ico and /apple-touch-icon.png answer the forge's icon, cached #6057

Parked opened this
Closed without merging

scout/forge:scout/6039-favicon-ico-and-apple-touch-icon-png-ans → main 2 commits fork

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
5 files changed +39 −2
src/core/reserved.ts +3
@@ -77,6 +77,9 @@ export const SYSTEM_NAMES: readonly string[] = [
7777 "live",
7878 "login",
7979 "logout",
80 "apple-touch-icon-precomposed.png",
81 "apple-touch-icon.png",
82 "favicon.ico",
8083 "manifest.webmanifest",
8184 "opensearch.xml",
8285 "map",
src/http/server.ts +5
@@ -183,6 +183,8 @@ import { ceilingAct, grantAct, modelAdd, modelPage } from "../web/pages/model.ts
183183 import {
184184 changePassword,
185185 iconPng,
186 faviconIco,
187 appleTouchIcon,
186188 llmsTxt,
187189 releasesJson,
188190 robotsTxt,
@@ -675,6 +677,9 @@ export function buildRouter(): Router<Handler> {
675677 router.add("GET", "/manifest.webmanifest", webManifest);
676678 router.add("GET", "/opensearch.xml", openSearch);
677679 router.add("GET", "/icons/:spec.png", iconPng);
680 router.add("GET", "/favicon.ico", faviconIco);
681 router.add("GET", "/apple-touch-icon.png", appleTouchIcon);
682 router.add("GET", "/apple-touch-icon-precomposed.png", appleTouchIcon);
678683 // The highlighter bundle, content-addressed. A stale hash is a 404 rather
679684 // than a redirect: the page that asked for it names the hash it was built
680685 // with, so a miss means an old tab, and an old tab should reload.
src/web/standards.ts +14 −1
@@ -243,7 +243,20 @@ export function iconPng(ctx: Ctx): Response {
243243 // iOS rounds its own corners, so the touch icon is painted edge to edge
244244 // like a maskable one.
245245 const shape: MarkShape = m[2] !== undefined || size === 180 ? "full" : "icon";
246 const png = markPng(size, shape);
246 return pngResponse(markPng(size, shape));
247 }
248
249 /** GET /favicon.ico — the 192 mark as a png; browsers sniff the bytes. */
250 export function faviconIco(): Response {
251 return pngResponse(markPng(192, "icon"));
252 }
253
254 /** GET /apple-touch-icon.png and -precomposed — the 180 edge-to-edge mark. */
255 export function appleTouchIcon(): Response {
256 return pngResponse(markPng(180, "full"));
257 }
258
259 function pngResponse(png: Uint8Array): Response {
247260 return new Response(png, {
248261 headers: {
249262 "content-type": "image/png",
test/design-audit.test.ts +1 −1
@@ -11,7 +11,7 @@ const doc = readFileSync("docs/design/audit.md", "utf8");
1111
1212 /** Routes that answer a file, a fragment, a redirect hop or a callback. */
1313 const NOT_PAGES =
14 /^\/(assets\/|\.well-known\/|icons\/|og\/|live\/|__forge\/|go\/|events$|system\/stream$|settings\/teams\/stream$|sw\.js$|robots\.txt$|sitemap\.xml$|manifest\.webmanifest$|opensearch\.xml$|llms\.txt$|releases\.json$|audit\.csv$|fleet\/graph\/live$|fleet\/graph\.csv$|settings\/origins\/callback$|home\/archived\/|settings\/backups\/live$)/;
14 /^\/(assets\/|\.well-known\/|icons\/|og\/|live\/|__forge\/|go\/|events$|system\/stream$|settings\/teams\/stream$|sw\.js$|favicon\.ico$|apple-touch-icon(-precomposed)?\.png$|robots\.txt$|sitemap\.xml$|manifest\.webmanifest$|opensearch\.xml$|llms\.txt$|releases\.json$|audit\.csv$|fleet\/graph\/live$|fleet\/graph\.csv$|settings\/origins\/callback$|home\/archived\/|settings\/backups\/live$)/;
1515
1616 const getRoutes = [
1717 ...server.matchAll(/router\.add\(\s*"GET",\s*"([^"]+)"/g),
test/standards.test.ts +16
@@ -287,6 +287,22 @@ describe("what the open web expects", () => {
287287 expect((await fetch(`${base}/icons/forge-64.png`)).status).toBe(404);
288288 });
289289
290 test("/favicon.ico and the root touch icons answer the mark, cached", async () => {
291 for (const path of [
292 "/favicon.ico",
293 "/apple-touch-icon.png",
294 "/apple-touch-icon-precomposed.png",
295 ]) {
296 const res = await fetch(`${base}${path}`);
297 expect(res.status).toBe(200);
298 expect(res.headers.get("content-type")).toBe("image/png");
299 expect(res.headers.get("cache-control")).toBe(
300 "public, max-age=604800, immutable",
301 );
302 expect(pngHeader(new Uint8Array(await res.arrayBuffer())).ok).toBe(true);
303 }
304 });
305
290306 test("the mark is painted, not pasted: gradient inside, nothing outside", () => {
291307 const decoded = decodePng(markPng(64, "icon"));
292308 expect(decoded.ok).toBe(true);

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs