16 lines
663 B
TypeScript
16 lines
663 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { redactAnalyticsCookie, redactAnalyticsUrl } from "./analytics-redaction";
|
|
|
|
describe("analytics redaction", () => {
|
|
it("removes query strings from absolute and relative URLs", () => {
|
|
expect(redactAnalyticsUrl("https://example.com/path?token=secret&email=a@example.com#section")).toBe("https://example.com/path#section");
|
|
expect(redactAnalyticsUrl("/checkout?session_id=secret")).toBe("/checkout");
|
|
});
|
|
|
|
it("does not expose raw visitor cookies", () => {
|
|
expect(redactAnalyticsCookie("abcdef123456")).toBe("abcde...");
|
|
expect(redactAnalyticsCookie("abc")).toBe("[redacted]");
|
|
});
|
|
});
|