/** Normalizes a route prefix to a leading slash with no trailing slash. */ export function normalize(path: string) { const normalized = path.startsWith('/') ? path : `/${path}` if (normalized.length > 1 && normalized.endsWith('/')) return normalized.slice(0, -1) return normalized } /** Joins URL path segments into one normalized absolute path. */ export function join(...segments: string[]) { const path = segments .flatMap((segment) => segment.split('/')) .filter(Boolean) .join('/') return path ? `/${path}` : '/' }