(encoded: string | null)
| 48 | } |
| 49 | |
| 50 | export function decodeTrail(encoded: string | null): TrailHop[] { |
| 51 | if (!encoded) return []; |
| 52 | const hops: TrailHop[] = []; |
| 53 | for (const token of encoded.split(',')) { |
| 54 | if (token.length < 2) continue; |
| 55 | const dir = CHAR_TO_DIR[token[0] as string]; |
| 56 | if (!dir) continue; |
| 57 | let id: string; |
| 58 | try { |
| 59 | id = decodeURIComponent(token.slice(1)); |
| 60 | } catch { |
| 61 | id = token.slice(1); |
| 62 | } |
| 63 | if (id) hops.push({ id, name: null, kind: null, dir }); |
| 64 | } |
| 65 | return hops; |
| 66 | } |
| 67 |
no test coverage detected