AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
import { describe, expect, test } from "bun:test";
import { readFileSync } from "node:fs";
import { isPublicPagePath, PUBLIC_PAGE_HEADERS } from "./public-page-headers.ts";
const readHeaderRules = (path) => {
const rules = new Map();
let current = null;
for (const line of readFileSync(path, "utf8").split("\n")) {
if (!line.trim() || line.trim().startsWith("#")) continue;
if (!line.startsWith(" ")) {
current = new Map();
rules.set(line.trim(), current);
continue;
}
const separator = line.indexOf(":");
current.set(line.slice(0, separator).trim(), line.slice(separator + 1).trim());
}
return rules;
};
describe("public page headers", () => {
test("matches share and form links only", () => {
expect(isPublicPagePath("/share/abc")).toBe(true);
expect(isPublicPagePath("/share/notebook/abc/memo")).toBe(true);
expect(isPublicPagePath("/form/abc")).toBe(true);
expect(isPublicPagePath("/")).toBe(false);
expect(isPublicPagePath("/settings")).toBe(false);
expect(isPublicPagePath("/shared")).toBe(false);
});
test("Cloudflare static asset rules send the same headers as the shared policy", () => {
const rules = readHeaderRules(new URL("../../../apps/web/public/_headers", import.meta.url));
for (const route of ["/share/*", "/form/*"]) {
expect(Object.fromEntries(rules.get(route) ?? [])).toEqual(PUBLIC_PAGE_HEADERS);
}
});
test("the Docker static server applies the policy to public app routes", () => {
const server = readFileSync(new URL("../../../scripts/self-hosted-server.mjs", import.meta.url), "utf8");
expect(server).toContain("...(isPublicPagePath(url.pathname) ? PUBLIC_PAGE_HEADERS : {})");
});
});