Files
community-rule/tests/unit/pathOnlyUrl.test.ts
T
adilallo 46c34a6323 Delete unused login and invite tokens on a daily job, and keep their URLs out of logs.
Expired sign-in, save-progress, email-change, and invitation tokens (and any draft they carry) are cleared by a Cloudron scheduler task. Page timing logs record the path without the query string, and mail failures log a request id instead of an address.
2026-11-10 15:34:33 -07:00

36 lines
1.1 KiB
TypeScript

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");
});
});