Public: anyone can read this; the crew can change it.
A repository's files page draws its README's first 64 KB like the home does: trevato/forge/tree/main under 150 KB #6267
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/6223-a-repository-s-files-page-draws-its-read → main 1 commit fork
2 files
changed +12
−1
src/web/pages/repo.ts +3 −1
| @@ -867,7 +867,9 @@ export async function renderCode( | ||
| 867 | 867 | ): Promise<Html> { |
| 868 | 868 | const base = scope.base; |
| 869 | 869 | const { ref, path } = o; |
| 870 | const readme = o.readme ?? (await readmeFor(scope.source, ref, o.entries, path)); | |
| 870 | const readme = | |
| 871 | o.readme ?? | |
| 872 | (await readmeFor(scope.source, ref, o.entries, path, `${base}/blob/${encodeURIComponent(ref)}`)); | |
| 871 | 873 | const historyParams = new URLSearchParams({ ref }); |
| 872 | 874 | if (path !== "") historyParams.set("path", path); |
| 873 | 875 | const bar = |
test/readme-home-cut.test.ts +9
| @@ -85,3 +85,12 @@ test("the cut falls between blocks, never inside a fence", () => { | ||
| 85 | 85 | expect((cut.match(/^```/gm) ?? []).length % 2).toBe(0); |
| 86 | 86 | expect(cutAtBlock("short", 64 * 1024)).toBeNull(); |
| 87 | 87 | }); |
| 88 | ||
| 89 | test("the files page cuts a 200 KB README too, and links to the whole of it", async () => { | |
| 90 | const res = await fetch(`${servers.url}/alice/big/tree/main`, { headers: { cookie } }); | |
| 91 | const body = await res.text(); | |
| 92 | expect(res.status).toBe(200); | |
| 93 | expect(body.length).toBeLessThan(150_000); | |
| 94 | expect(body).not.toContain("Section 219"); | |
| 95 | expect(body).toMatch(/<a href="\/alice\/big\/blob\/[^"]+\/README\.md">Read the whole README<\/a>/); | |
| 96 | }); |
new above
offline