/favicon.ico and /apple-touch-icon.png answer the forge's icon, cached #6057
Parked
scoutcrew
opened this
Closed without merging
scout/forge:scout/6039-favicon-ico-and-apple-touch-icon-png-ans → main
·
2 commits
·fork
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[] = [ |
| 77 | 77 |
"live", |
| 78 | 78 |
"login", |
| 79 | 79 |
"logout", |
| 80 |
"apple-touch-icon-precomposed.png", |
| 81 |
"apple-touch-icon.png", |
| 82 |
"favicon.ico", |
| 80 | 83 |
"manifest.webmanifest", |
| 81 | 84 |
"opensearch.xml", |
| 82 | 85 |
"map", |
src/http/server.ts
+5
|
|
@@ -183,6 +183,8 @@ import { ceilingAct, grantAct, modelAdd, modelPage } from "../web/pages/model.ts |
| 183 | 183 |
import { |
| 184 | 184 |
changePassword, |
| 185 | 185 |
iconPng, |
| 186 |
faviconIco, |
| 187 |
appleTouchIcon, |
| 186 | 188 |
llmsTxt, |
| 187 | 189 |
releasesJson, |
| 188 | 190 |
robotsTxt, |
|
|
@@ -675,6 +677,9 @@ export function buildRouter(): Router<Handler> { |
| 675 | 677 |
router.add("GET", "/manifest.webmanifest", webManifest); |
| 676 | 678 |
router.add("GET", "/opensearch.xml", openSearch); |
| 677 | 679 |
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); |
| 678 | 683 |
|
| 679 | 684 |
|
| 680 | 685 |
|
src/web/standards.ts
+14
−1
|
|
@@ -243,7 +243,20 @@ export function iconPng(ctx: Ctx): Response { |
| 243 | 243 |
|
| 244 | 244 |
|
| 245 | 245 |
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 |
|
| 250 |
export function faviconIco(): Response { |
| 251 |
return pngResponse(markPng(192, "icon")); |
| 252 |
} |
| 253 |
|
| 254 |
|
| 255 |
export function appleTouchIcon(): Response { |
| 256 |
return pngResponse(markPng(180, "full")); |
| 257 |
} |
| 258 |
|
| 259 |
function pngResponse(png: Uint8Array): Response { |
| 247 | 260 |
return new Response(png, { |
| 248 | 261 |
headers: { |
| 249 | 262 |
"content-type": "image/png", |
test/design-audit.test.ts
+1
−1
|
|
@@ -11,7 +11,7 @@ const doc = readFileSync("docs/design/audit.md", "utf8"); |
| 11 | 11 |
|
| 12 | 12 |
|
| 13 | 13 |
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$)/; |
| 15 | 15 |
|
| 16 | 16 |
const getRoutes = [ |
| 17 | 17 |
...server.matchAll(/router\.add\(\s*"GET",\s*"([^"]+)"/g), |
test/standards.test.ts
+16
|
|
@@ -287,6 +287,22 @@ describe("what the open web expects", () => { |
| 287 | 287 |
expect((await fetch(`${base}/icons/forge-64.png`)).status).toBe(404); |
| 288 | 288 |
}); |
| 289 | 289 |
|
| 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 |
|
| 290 | 306 |
test("the mark is painted, not pasted: gradient inside, nothing outside", () => { |
| 291 | 307 |
const decoded = decodePng(markPng(64, "icon")); |
| 292 | 308 |
expect(decoded.ok).toBe(true); |