Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | /** * Route parameter and query parsing helpers * Centralizes route param type handling to avoid runtime checks in components */ import type { LocationQueryValue } from 'vue-router' /** * Parse a route param (string | string[] | undefined) to a number ID * Returns null if param is missing or invalid */ export function parseRouteId(param: string | string[] | undefined): number | null { if (!param) return null const str = Array.isArray(param) ? param[0] : param if (!str) return null const id = parseInt(str, 10) return isNaN(id) || id < 0 ? null : id } /** * Parse a route query param to a string * Returns empty string if param is missing, null, or is an array */ export function parseQueryString(param: LocationQueryValue | LocationQueryValue[] | undefined): string { if (!param) return '' return Array.isArray(param) ? '' : param } |