import { describe, expect, it } from "vitest"; import { pathOnlyUrl } from "../../lib/server/pathOnlyUrl"; describe("pathOnlyUrl", () => { it("drops the query string from an absolute URL", () => { expect( pathOnlyUrl( "https://communityrule.info/api/auth/magic-link/verify?token=secret", ), ).toBe("https://communityrule.info/api/auth/magic-link/verify"); }); it("drops invite tokens and hashes", () => { expect( pathOnlyUrl( "https://communityrule.info/api/invites/rule-stakeholder/verify?token=abc#frag", ), ).toBe( "https://communityrule.info/api/invites/rule-stakeholder/verify", ); }); it("keeps a share path with no query string", () => { expect(pathOnlyUrl("https://communityrule.info/r/share-slug")).toBe( "https://communityrule.info/r/share-slug", ); }); it("strips a relative URL at the first ? or #", () => { expect(pathOnlyUrl("/create/community-name?facet.size=small")).toBe( "/create/community-name", ); expect(pathOnlyUrl("/login#sent")).toBe("/login"); }); });