(href: HrefLiteral, table: RouteTable)
| 186 | * names a path it did not take. |
| 187 | */ |
| 188 | export function destinationsForHref(href: HrefLiteral, table: RouteTable): HrefDestination[] { |
| 189 | const out: HrefDestination[] = []; |
| 190 | const seen = new Set<string>(); |
| 191 | for (const arm of hrefArms(href)) { |
| 192 | const segs = hrefSegments(arm); |
| 193 | if (segs === null) continue; |
| 194 | const target = matchRoute(segs, table); |
| 195 | // An arm naming no route drops out; the arms that DO name one are still |
| 196 | // places this navigation goes. |
| 197 | if (!target || seen.has(target.id)) continue; |
| 198 | seen.add(target.id); |
| 199 | out.push({ node: target, href: arm }); |
| 200 | } |
| 201 | return out; |
| 202 | } |
| 203 | |
| 204 | /** The single route an href names, or null when it names none. The first arm wins a fork. */ |
| 205 | export function pageForHref(href: HrefLiteral, table: RouteTable): Node | null { |
no test coverage detected