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

Function chainToSegments

core/src/components/router/utils/path.ts:50–67  ·  view source on GitHub ↗
(chain: RouteChain)

Source from the content-addressed store, hash-verified

48 * - null is returned when a value is missing for any parameter segment.
49 */
50export const chainToSegments = (chain: RouteChain): string[] | null => {
51 const segments = [];
52 for (const route of chain) {
53 for (const segment of route.segments) {
54 if (segment[0] === ':') {
55 // eslint-disable-next-line @typescript-eslint/prefer-optional-chain
56 const param = route.params && route.params[segment.slice(1)];
57 if (!param) {
58 return null;
59 }
60 segments.push(param);
61 } else if (segment !== '') {
62 segments.push(segment);
63 }
64 }
65 }
66 return segments;
67};
68
69/**
70 * Removes the prefix segments from the path segments.

Callers 3

navChangedMethod · 0.90
getRoutePathFunction · 0.90
path.spec.tsxFile · 0.90

Calls 1

pushMethod · 0.45

Tested by 1

getRoutePathFunction · 0.72