diff --git a/frontend/src/routes/+page.server.ts b/frontend/src/routes/+page.server.ts index def3534f..da2a12e2 100644 --- a/frontend/src/routes/+page.server.ts +++ b/frontend/src/routes/+page.server.ts @@ -19,7 +19,12 @@ export async function load({ url, fetch }) { const sort: ValidSort = (VALID_SORTS as readonly string[]).includes(rawSort) ? (rawSort as ValidSort) : 'DATE'; - const dir = url.searchParams.get('dir') || 'desc'; + const VALID_DIRS = ['asc', 'desc'] as const; + type ValidDir = (typeof VALID_DIRS)[number]; + const rawDir = url.searchParams.get('dir') ?? 'desc'; + const dir: ValidDir = (VALID_DIRS as readonly string[]).includes(rawDir) + ? (rawDir as ValidDir) + : 'desc'; const tagQ = url.searchParams.get('tagQ') || ''; const isDashboard = !q && !from && !to && !senderId && !receiverId && !tags.length && !tagQ;