MCPcopy
hub / github.com/angular/angular / updateSegmentGroup

Function updateSegmentGroup

packages/router/src/create_url_tree.ts:383–411  ·  view source on GitHub ↗
(
  segmentGroup: UrlSegmentGroup | undefined,
  startIndex: number,
  commands: readonly any[],
)

Source from the content-addressed store, hash-verified

381}
382
383function updateSegmentGroup(
384 segmentGroup: UrlSegmentGroup | undefined,
385 startIndex: number,
386 commands: readonly any[],
387): UrlSegmentGroup {
388 segmentGroup ??= new UrlSegmentGroup([], {});
389 if (segmentGroup.segments.length === 0 && segmentGroup.hasChildren()) {
390 return updateSegmentGroupChildren(segmentGroup, startIndex, commands);
391 }
392
393 const m = prefixedWith(segmentGroup, startIndex, commands);
394 const slicedCommands = commands.slice(m.commandIndex);
395 if (m.match && m.pathIndex < segmentGroup.segments.length) {
396 const g = new UrlSegmentGroup(segmentGroup.segments.slice(0, m.pathIndex), {});
397 g.children[PRIMARY_OUTLET] = new UrlSegmentGroup(
398 segmentGroup.segments.slice(m.pathIndex),
399 segmentGroup.children,
400 );
401 return updateSegmentGroupChildren(g, 0, slicedCommands);
402 } else if (m.match && slicedCommands.length === 0) {
403 return new UrlSegmentGroup(segmentGroup.segments, {});
404 } else if (m.match && !segmentGroup.hasChildren()) {
405 return createNewSegmentGroup(segmentGroup, startIndex, commands);
406 } else if (m.match) {
407 return updateSegmentGroupChildren(segmentGroup, 0, slicedCommands);
408 } else {
409 return createNewSegmentGroup(segmentGroup, startIndex, commands);
410 }
411}
412
413function updateSegmentGroupChildren(
414 segmentGroup: UrlSegmentGroup,

Callers 2

Calls 4

prefixedWithFunction · 0.85
createNewSegmentGroupFunction · 0.85
hasChildrenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…