fix(seerr): guard SeerrItemRouter query params against undefined

releaseYear and mediaType are typed as required but can be undefined or
NaN at runtime, so .toString() could throw inside the onPress handler.
Coerce every value with String(... ?? fallback).
This commit is contained in:
Uruk
2026-05-22 01:44:20 +02:00
parent 9cc119894f
commit bd88de8a90

View File

@@ -42,7 +42,9 @@ export const TouchableSeerrRouter: React.FC<PropsWithChildren<Props>> = ({
onPress={() => {
if (!result) return;
// Build URL with query params - avoids Expo Router's strict type checking
// Build URL with query params - avoids Expo Router's strict type checking.
// Every value is coerced defensively: releaseYear/mediaType can be
// undefined or NaN at runtime, so `.toString()` would throw.
const params = new URLSearchParams({
...Object.fromEntries(
Object.entries(result).map(([key, value]) => [
@@ -50,11 +52,11 @@ export const TouchableSeerrRouter: React.FC<PropsWithChildren<Props>> = ({
String(value ?? ""),
]),
),
mediaTitle,
releaseYear: releaseYear.toString(),
canRequest: canRequest.toString(),
posterSrc,
mediaType: mediaType.toString(),
mediaTitle: mediaTitle ?? "",
releaseYear: String(releaseYear ?? ""),
canRequest: String(canRequest ?? false),
posterSrc: posterSrc ?? "",
mediaType: String(mediaType ?? ""),
});
router.push(