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 | import assert from "node:assert/strict"; |
| 2 | import { test } from "node:test"; | |
| 3 | ||
| 4 | import { repositoryOfPage, stillPublic } from "./public-cache.ts"; | |
| 5 | ||
| 6 | test("a project page names its repository", () => { | |
| 7 | assert.equal(repositoryOfPage("/flagon-io/hello"), "flagon-io/hello"); | |
| 8 | assert.equal(repositoryOfPage("/flagon-io/hello.data"), "flagon-io/hello"); | |
| 9 | assert.equal(repositoryOfPage("/Flagon-IO/Hello/issues/4"), "flagon-io/hello"); | |
| 10 | assert.equal(repositoryOfPage("/flagon-io/hello/blob/main/src/lib.rs"), "flagon-io/hello"); | |
| 11 | }); | |
| 12 | ||
| 13 | test("pages that are not a repository's name none", () => { | |
| 14 | assert.equal(repositoryOfPage("/"), null); | |
| 15 | assert.equal(repositoryOfPage("/pricing"), null); | |
| 16 | assert.equal(repositoryOfPage("/flagon-io"), null); | |
| 17 | assert.equal(repositoryOfPage("/flagon-io/-"), null); | |
| 18 | }); | |
| 19 | ||
| 20 | test("only a repository that is there and public is served from the cache", () => { | |
| 21 | assert.equal(stillPublic([{ path: "a/b", is_private: false }], "a/b"), true); | |
| 22 | assert.equal(stillPublic([{ path: "a/b", is_private: true }], "a/b"), false); | |
| 23 | // Deleted or never there: repos leaves it out. | |
| 24 | assert.equal(stillPublic([], "a/b"), false); | |
| 25 | assert.equal(stillPublic(null, "a/b"), false); | |
| 26 | assert.equal(stillPublic([{ path: "a/c", is_private: false }], "a/b"), false); | |
| 27 | }); |