import { describe, expect, it } from "vitest"; import { parseUpdateTarget } from "./publish.js"; describe("parseUpdateTarget", () => { it("extracts the id from a full published URL", () => { expect(parseUpdateTarget("https://hyperframes.dev/p/hfp_abc123")).toBe("hfp_abc123"); }); it("handles a scheme-less URL (which new URL() rejects)", () => { expect(parseUpdateTarget("hyperframes.dev/p/hfp_abc123")).toBe("hfp_abc123"); }); it("strips a trailing query and hash", () => { expect(parseUpdateTarget("https://hyperframes.dev/p/hfp_abc123?claim_token=x#frag")).toBe( "hfp_abc123", ); }); it("accepts a bare id unchanged and trims surrounding whitespace", () => { expect(parseUpdateTarget(" hfp_abc123 ")).toBe("hfp_abc123"); }); it("falls back to the last path segment for a non-/p/ URL", () => { expect(parseUpdateTarget("https://example.com/foo/hfp_abc123")).toBe("hfp_abc123"); }); });