MCPcopy Create free account
hub / github.com/angular/angular / containsSegmentGroupHelper

Function containsSegmentGroupHelper

packages/router/src/url_tree.ts:208–243  ·  view source on GitHub ↗
(
  container: UrlSegmentGroup,
  containee: UrlSegmentGroup,
  containeePaths: UrlSegment[],
  matrixParams: ParamMatchOptions,
)

Source from the content-addressed store, hash-verified

206}
207
208function containsSegmentGroupHelper(
209 container: UrlSegmentGroup,
210 containee: UrlSegmentGroup,
211 containeePaths: UrlSegment[],
212 matrixParams: ParamMatchOptions,
213): boolean {
214 if (container.segments.length > containeePaths.length) {
215 const current = container.segments.slice(0, containeePaths.length);
216 if (!equalPath(current, containeePaths)) return false;
217 if (containee.hasChildren()) return false;
218 if (!matrixParamsMatch(current, containeePaths, matrixParams)) return false;
219 return true;
220 } else if (container.segments.length === containeePaths.length) {
221 if (!equalPath(container.segments, containeePaths)) return false;
222 if (!matrixParamsMatch(container.segments, containeePaths, matrixParams)) return false;
223 for (const c in containee.children) {
224 if (!container.children[c]) return false;
225 if (!containsSegmentGroup(container.children[c], containee.children[c], matrixParams)) {
226 return false;
227 }
228 }
229 return true;
230 } else {
231 const current = containeePaths.slice(0, container.segments.length);
232 const next = containeePaths.slice(container.segments.length);
233 if (!equalPath(container.segments, current)) return false;
234 if (!matrixParamsMatch(container.segments, current, matrixParams)) return false;
235 if (!container.children[PRIMARY_OUTLET]) return false;
236 return containsSegmentGroupHelper(
237 container.children[PRIMARY_OUTLET],
238 containee,
239 next,
240 matrixParams,
241 );
242 }
243}
244
245function matrixParamsMatch(
246 containerPaths: UrlSegment[],

Callers 1

containsSegmentGroupFunction · 0.85

Calls 5

equalPathFunction · 0.85
matrixParamsMatchFunction · 0.85
containsSegmentGroupFunction · 0.85
sliceMethod · 0.65
hasChildrenMethod · 0.45

Tested by

no test coverage detected