/** Parses a numeric route param (e.g. /admin/posts/[id]); null when invalid. */ export function parseIdParam(raw: string): number | null { if (!/^\d+$/.test(raw)) return null; const id = Number.parseInt(raw, 10); return Number.isSafeInteger(id) && id > 0 ? id : null; }