(raw: string)
| 78 | * Returns null for a path that names no address at all. |
| 79 | */ |
| 80 | export function tanstackPath(raw: string): string | null { |
| 81 | if (!raw.startsWith('/')) return null; |
| 82 | const segs: string[] = []; |
| 83 | for (const seg of raw.split('/')) { |
| 84 | if (seg.length === 0) continue; |
| 85 | if (seg.startsWith('_')) continue; // pathless layout |
| 86 | if (seg.startsWith('(') && seg.endsWith(')')) continue; // route group |
| 87 | const bare = seg.endsWith('_') ? seg.slice(0, -1) : seg; |
| 88 | if (bare === '$') { |
| 89 | segs.push(':splat*'); |
| 90 | continue; |
| 91 | } |
| 92 | segs.push(bare.startsWith('$') ? ':' + bare.slice(1) : bare); |
| 93 | } |
| 94 | return '/' + segs.join('/'); |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * True when the literal names a pathless layout rather than a page. |
no test coverage detected