Files
hcl-finances-manager/tests/lib/safe-return.test.ts
T
YugonitoandClaude Opus 5.5 5b402691f0 fix: opening balance direction, safe return paths, backup failure detection, review fixes
- opening balance: "person 2 owes person 1" was stored the wrong way round
- retour param: reject backslash/control chars (open redirect)
- backup: pipefail + check dump completeness, failed dumps no longer logged OK
- deleting a recurring occurrence marks it skipped so sync does not recreate it
- editing a charge regenerates future occurrences of incomes allocated to it
- settlements (incl. opening balance) listed in settings and deletable

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 18:51:49 +01:00

16 lines
638 B
TypeScript

import { describe, expect, it } from "vitest";
import { safeReturn } from "@/lib/safe-return";
describe("safeReturn", () => {
it("keeps internal paths with their query string", () => {
expect(safeReturn("/operations?m=2026-10&q=a", "/")).toBe("/operations?m=2026-10&q=a");
expect(safeReturn("/", "/x")).toBe("/");
});
it("falls back for anything that could leave the site", () => {
for (const bad of [undefined, "", "https://evil.com", "//evil.com", "/\\evil.com", "/%09/evil.com", "\t//evil.com", "javascript:alert(1)", "/\t/evil.com"]) {
expect(safeReturn(bad, "/fallback")).toBe("/fallback");
}
});
});