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:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user