MCPcopy Index your code
hub / github.com/angular/angular / match

Function match

packages/router/src/utils/config_matching.ts:82–122  ·  view source on GitHub ↗
(
  segmentGroup: UrlSegmentGroup,
  route: Route,
  segments: UrlSegment[],
)

Source from the content-addressed store, hash-verified

80}
81
82export function match(
83 segmentGroup: UrlSegmentGroup,
84 route: Route,
85 segments: UrlSegment[],
86): MatchResult {
87 if (route.path === '') {
88 if (route.pathMatch === 'full' && (segmentGroup.hasChildren() || segments.length > 0)) {
89 return {...noMatch};
90 }
91
92 return {
93 matched: true,
94 consumedSegments: [],
95 remainingSegments: segments,
96 parameters: {},
97 positionalParamSegments: {},
98 };
99 }
100
101 const matcher = route.matcher || defaultUrlMatcher;
102 const res = matcher(segments, segmentGroup, route);
103 if (!res) return {...noMatch};
104
105 const posParams: {[n: string]: string} = {};
106 Object.entries(res.posParams ?? {}).forEach(([k, v]) => {
107 posParams[k] = v.path;
108 });
109 const parameters =
110 res.consumed.length > 0
111 ? {...posParams, ...res.consumed[res.consumed.length - 1].parameters}
112 : posParams;
113
114 return {
115 matched: true,
116 consumedSegments: res.consumed,
117 remainingSegments: segments.slice(res.consumed.length),
118 // TODO(atscott): investigate combining parameters and positionalParamSegments
119 parameters,
120 positionalParamSegments: res.posParams ?? {},
121 };
122}
123
124export function split(
125 segmentGroup: UrlSegmentGroup,

Callers 3

_matchMethod · 0.85
matchWithChecksFunction · 0.85

Calls 4

matcherFunction · 0.50
hasChildrenMethod · 0.45
forEachMethod · 0.45
entriesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…