| 154 | * That is they contain both the componentProps of the <ion-route> and the parameter segment. |
| 155 | */ |
| 156 | export const findChainForIDs = (ids: RouteID[], chains: RouteChain[]): RouteChain | null => { |
| 157 | let match: RouteChain | null = null; |
| 158 | let maxMatches = 0; |
| 159 | |
| 160 | for (const chain of chains) { |
| 161 | const score = matchesIDs(ids, chain); |
| 162 | if (score > maxMatches) { |
| 163 | match = chain; |
| 164 | maxMatches = score; |
| 165 | } |
| 166 | } |
| 167 | if (match) { |
| 168 | return match.map((route, i) => ({ |
| 169 | id: route.id, |
| 170 | segments: route.segments, |
| 171 | params: mergeParams(route.params, ids[i]?.params), |
| 172 | })); |
| 173 | } |
| 174 | return null; |
| 175 | }; |
| 176 | |
| 177 | /** |
| 178 | * Finds the best match for the segments in the chains. |