Something went wrong. Try again.
Monorepo for Tangled tangled.org
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536import { describe, expect, it } from "vitest";import { profileLinkTarget } from "#lib/components/profile/profileLinks.ts";
describe("profileLinkTarget", () => { it("labels web links by host", () => { expect(profileLinkTarget("https://ops.sub.example.co.uk/about?x=1")).toEqual({ href: "https://ops.sub.example.co.uk/about?x=1", label: "ops.sub.example.co.uk", external: true }); });
it("opens account links on tangled", () => { expect(profileLinkTarget("at://did:plc:abc")).toEqual({ href: "/did:plc:abc", label: "did:plc:abc", external: false }); expect(profileLinkTarget("did:plc:abc")?.href).toBe("/did:plc:abc"); });
it("opens record links in an atproto browser", () => { expect(profileLinkTarget("at://did:plc:abc/app.bsky.feed.post/3kabc")).toEqual({ href: "https://pdsls.dev/at://did:plc:abc/app.bsky.feed.post/3kabc", label: "did:plc:abc/app.bsky.feed.post/3kabc", external: true }); });
it("refuses schemes that cannot be followed safely", () => { expect(profileLinkTarget("javascript:alert(1)")).toBeNull(); expect(profileLinkTarget("ftp://files.example.com")).toBeNull(); expect(profileLinkTarget("settings")).toBeNull(); });});