`/users/${…}?tab=x` → `['users', '*']`; an absolute URL keeps its path; a relative href is nothing.
(href: HrefLiteral)
| 152 | |
| 153 | /** `/users/${…}?tab=x` → `['users', '*']`; an absolute URL keeps its path; a relative href is nothing. */ |
| 154 | function hrefSegments(href: HrefLiteral): string[] | null { |
| 155 | let p = href.path; |
| 156 | const absolute = /^(?:[a-z][a-z0-9+.-]*:)?\/\/[^/]*(\/.*)?$/i.exec(p); |
| 157 | if (absolute) p = absolute[1] ?? '/'; |
| 158 | if (!p.startsWith('/')) return null; |
| 159 | return p |
| 160 | .split('/') |
| 161 | .slice(1) |
| 162 | .filter((s) => s.length > 0) |
| 163 | .map((s) => (s.includes(HOLE) ? '*' : decode(s))); |
| 164 | } |
| 165 | |
| 166 | function decode(s: string): string { |
| 167 | try { |
no test coverage detected