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

`GET /og/app/:ref.svg` and `/og/repo/:ref.svg` serve a live card with an ETag, and `og` is a reserved name #1638

Closed opened this
Closed without merging

GET /og/app/:slug.svg and GET /og/repo/:owner:name.svg now serve a live card. og is a reserved name, so test/reserved-names.test.ts stays green. The new route test, the reserved-names and card tests, check-list and tsc --noEmit all pass here.

Notes

stopped closed without shipping deploy 21f1bed

opened this

GET /og/app/:slug.svg and GET /og/repo/:owner~:name.svg now serve a live card. og is a reserved name, so test/reserved-names.test.ts stays green. The new route test, the reserved-names and card tests, check-list and tsc --noEmit all pass here. I didn't run the whole check.

  • Route: src/web/pages/og.ts is registered in src/http/server.ts above /:owner. It draws the card with the #1470 renderer.
  • Refs:
    • A repo ref is owner~name. I chose ~ because it can't appear in a repo or owner name, so the ref stays one path segment.
    • An app ref is its slug.
    • Refs are validated at the boundary.
  • Private and bad refs: a private repo, or an app whose repo the viewer can't read, answers 404. So does an unknown kind, an unknown name or a malformed ref, so a card never confirms a private name.
  • Caching:
    • The ETag is the sha256 of the card inputs, and a matching If-None-Match gets a 304.
    • Rendered SVG is cached in memory by the same hash, with a cap of 256 cards.
    • Cache-Control is public, max-age=300.
  • Headers: image/svg+xml, nosniff, Referrer-Policy and a default-src 'none' CSP are set on the response itself.
  • Escaping: all text goes through the renderer's escaping.
  • Tests: test/og-route.test.ts is named in GATE. It covers 200 with headers, the 404 cases, ETag and 304, and a warm request under 50 ms.
  • Left out: the issue, pull and run kinds. These two kinds were all this issue asked for, and other kinds answer 404.

To try it, open /og/repo/<owner>~<name>.svg or /og/app/<slug>.svg on a public repo or app. Send the response's ETag back as If-None-Match to get a 304.

Dependencies: none added.

Closes #1590

commented

Parked by the crew: the check failed in the place it ran, not in the change, and failed the same way when it was run again

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs