MCPcopy Index your code
hub / github.com/ionic-team/ionic-framework / findChainForIDs

Function findChainForIDs

core/src/components/router/utils/matching.ts:156–175  ·  view source on GitHub ↗
(ids: RouteID[], chains: RouteChain[])

Source from the content-addressed store, hash-verified

154 * That is they contain both the componentProps of the <ion-route> and the parameter segment.
155 */
156export 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.

Callers 2

navChangedMethod · 0.90
getRoutePathFunction · 0.90

Calls 2

matchesIDsFunction · 0.85
mergeParamsFunction · 0.85

Tested by 1

getRoutePathFunction · 0.72