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 {
getAttachmentFilenameFromLabel,
getAttachmentResourceId,
} from "./attachment-links.ts";
describe("attachment links", () => {
test("extracts resource ids from API and desktop URLs", () => {
expect(getAttachmentResourceId("/api/v1/resources/res_123/blob")).toBe("res_123");
expect(getAttachmentResourceId("https://notes.example.com/api/v1/resources/res%20one/blob?download=1")).toBe("res one");
expect(getAttachmentResourceId("edgeever-resource://resource/res_456")).toBe("res_456");
});
test("ignores unrelated and staged URLs", () => {
expect(getAttachmentResourceId("https://example.com/file.zip")).toBeNull();
expect(getAttachmentResourceId("edgeever-staged://stage_1")).toBeNull();
});
test("extracts filenames from localized attachment labels", () => {
expect(getAttachmentFilenameFromLabel("附件:archive.zip")).toBe("archive.zip");
expect(getAttachmentFilenameFromLabel("Attachment: report.pdf")).toBe("report.pdf");
});
});