fix(frontend): normalize empty ?claim= to null; preserve sibling params

- readClaimId: URLSearchParams.get returns '' for ?claim=, not null.
  Normalize to null so the contract matches the JSDoc and consumers
  can treat empty as absent.

- Tests: regression for ?claim= → null; open/close preserves other
  query params (?foo=bar survives open/close unchanged).

- Tighten pushStateMock/replaceStateMock typing to vi.fn<() => void>()
  per code-review nit (drops the verbose ReturnType<typeof vi.fn>).
This commit is contained in:
Tyler
2026-06-20 10:52:42 -06:00
parent 234cd8b28b
commit e7469d39ec
2 changed files with 51 additions and 3 deletions
+5 -1
View File
@@ -11,7 +11,11 @@ import { useCallback, useEffect, useState } from "react";
*/
function readClaimId(): string | null {
const params = new URLSearchParams(window.location.search);
return params.get("claim");
// `URLSearchParams.get` returns `""` for `?claim=` (param present but
// empty) — we normalize that to `null` so the "absent" and "empty"
// cases are indistinguishable to consumers, matching the JSDoc.
const value = params.get("claim");
return value === "" ? null : value;
}
/**