Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Signed-out page cache: a repository's kept page is served only while the repository is still public, so one made private or deleted never shows from any data centre's copy | 1 | /** |
| 2 | * The signed-out page cache (workers/app.ts) keeps a repository's pages for | |
| 3 | * visitors who are not signed in. Before a kept page is served, the | |
| 4 | * repository is asked for again: one that was made private, or deleted, | |
| 5 | * since the page was kept is never served from the cache, wherever it was | |
| 6 | * kept. This says which repository a kept page belongs to. | |
| 7 | */ | |
| 8 | ||
| 9 | /** `<workspace>/<repository>` of a project page's path, or null for any other page. */ | |
| 10 | export function repositoryOfPage(pathname: string): string | null { | |
| 11 | const [, workspace, rest] = /^\/([^/]+)\/([^/]+)/.exec(pathname) ?? []; | |
| 12 | if (!workspace || !rest || rest === "-") return null; | |
| 13 | const name = rest.replace(/\.data$/, ""); | |
| 14 | if (!name) return null; | |
| 15 | return `${decodeURIComponent(workspace).toLowerCase()}/${decodeURIComponent(name).toLowerCase()}`; | |
| 16 | } | |
| 17 | ||
| 18 | /** Whether repos' `visibility` answer says the repository is still there and public. */ | |
| 19 | export function stillPublic(answer: unknown, path: string): boolean { | |
| 20 | if (!Array.isArray(answer)) return false; | |
| 21 | const found = answer.find((v): v is { path: string; is_private: boolean } => { | |
| 22 | return typeof v === "object" && v !== null && (v as { path?: unknown }).path === path; | |
| 23 | }); | |
| 24 | return found !== undefined && found.is_private === false; | |
| 25 | } |