diff --git a/pkgs/id/web/src/header-subtitle.test.ts b/pkgs/id/web/src/header-subtitle.test.ts
new file mode 100644
index 0000000000..f3a67f0566
--- /dev/null
+++ b/pkgs/id/web/src/header-subtitle.test.ts
@@ -0,0 +1,66 @@
+import { describe, expect, it } from "vitest";
+import { updateHeaderSubtitle } from "./header-subtitle";
+
+function renderSubtitle(filename: string, path: string): HTMLElement {
+ document.body.innerHTML = "";
+ const subtitle = document.createElement("div");
+ subtitle.id = "header-subtitle";
+ document.body.appendChild(subtitle);
+ updateHeaderSubtitle(filename, path, true);
+ return subtitle;
+}
+
+describe("header subtitle", () => {
+ it("renders a markup-carrying filename as literal text, not elements", () => {
+ const label = '
.md';
+ const subtitle = renderSubtitle(label, "/edit/" + label);
+
+ expect(subtitle.querySelector("img")).toBeNull();
+ const link = subtitle.querySelector("a");
+ expect(link).not.toBeNull();
+ expect(link?.textContent).toBe(label);
+ expect(link?.getAttribute("data-nav")).toBe("");
+ expect(subtitle.querySelectorAll("a")).toHaveLength(1);
+ });
+
+ it("cannot be broken out of by an anchor-closing filename", () => {
+ const label = "x