Something went wrong. Try again.
My website. cameron.stream
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061import assert from "node:assert/strict";import { readFile } from "node:fs/promises";import test from "node:test";import { Hono } from "hono";import { renderToReadableStream } from "hono/jsx/streaming";import { LinksContent } from "./components/links.tsx";import { otherEntries } from "./components/other-index.tsx";import { PageNav } from "./components/page-nav.tsx";import { Shell } from "./components/shell.tsx";import { canonicalizeTrailingSlash } from "./trailing-slash.ts";import type { SembleData } from "./data.ts";
const data: SembleData = { available: true, collections: [], cards: ["https://example.org/reading", "javascript:alert(1)", "not a URL"].map((url, i) => ({ id: String(i), type: "URL", url, cardContent: { url, title: "Reading <notes>", description: "Public & saved" }, createdAt: "2026-09-07", updatedAt: "2026-09-07", collections: [], author: { id: "fixture", handle: "example.org" }, })),};
async function render(component: Parameters<typeof renderToReadableStream>[0]) { return new Response(renderToReadableStream(component)).text();}
test("Links renders public bookmarks in the standard shell with Other active", async () => { const html = await render(<Shell title="Links"><div><PageNav profile={null} active="other" /><LinksContent data={data} /></div></Shell>); assert.match(html, /<title>Links — Cameron's website<\/title>/); assert.match(html, /class="page-container"/); assert.match(html, /href="\/other" class="active" aria-current="page"/); assert.match(html, /<h1 class="page-title">Links<\/h1>/); assert.match(html, /href="https:\/\/example.org\/reading"/); assert.match(html, /Reading <notes>/); assert.match(html, /https:\/\/semble.so\/profile\/cameron.stream/); assert.doesNotMatch(html, /javascript:|not a URL|mailto:|noindex/); assert.equal(otherEntries.filter((entry) => entry.href === "/links").length, 1);});
test("Links distinguishes an upstream failure from an empty collection", async () => { assert.match(await render(<LinksContent data={{ cards: [], collections: [], available: false }} />), /could not be loaded/); assert.match(await render(<LinksContent data={{ cards: [], collections: [], available: true }} />), /No saved links yet/);});
test("Links is a standalone route; old catalogue routes no longer target a missing fragment", async () => { const source = await readFile(new URL("./index.tsx", import.meta.url), "utf8"); assert.match(source, /app.get\("\/links",[\s\S]*?<Shell title="Links">\s*<Links \/>/); for (const alias of ["library", "semble"]) { assert.ok(source.includes(`app.get("/${alias}", (c) => c.redirect("/links", 301))`)); } const app = new Hono(); app.use(canonicalizeTrailingSlash); app.get("/links", (c) => c.text("Links")); assert.equal((await app.request("/links")).status, 200); for (const method of ["GET", "HEAD"]) { const response = await app.request("/links/?from=about", { method }); assert.equal(response.status, 301); assert.equal(response.headers.get("location"), "/links?from=about"); }});