MCPcopy
hub / github.com/angular/angular / createNewSegmentGroup

Function createNewSegmentGroup

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

Source from the content-addressed store, hash-verified

508}
509
510function createNewSegmentGroup(
511 segmentGroup: UrlSegmentGroup,
512 startIndex: number,
513 commands: readonly any[],
514): UrlSegmentGroup {
515 const paths = segmentGroup.segments.slice(0, startIndex);
516
517 let i = 0;
518 while (i < commands.length) {
519 const command = commands[i];
520 if (isCommandWithOutlets(command)) {
521 const children = createNewSegmentChildren(command.outlets);
522 return new UrlSegmentGroup(paths, children);
523 }
524
525 // if we start with an object literal, we need to reuse the path part from the segment
526 if (i === 0 && isMatrixParams(commands[0])) {
527 const p = segmentGroup.segments[startIndex];
528 paths.push(new UrlSegment(p.path, stringify(commands[0])));
529 i++;
530 continue;
531 }
532
533 const curr = isCommandWithOutlets(command) ? command.outlets[PRIMARY_OUTLET] : `${command}`;
534 const next = i < commands.length - 1 ? commands[i + 1] : null;
535 if (curr && next && isMatrixParams(next)) {
536 paths.push(new UrlSegment(curr, stringify(next)));
537 i += 2;
538 } else {
539 paths.push(new UrlSegment(curr, {}));
540 i++;
541 }
542 }
543 return new UrlSegmentGroup(paths, {});
544}
545
546function createNewSegmentChildren(outlets: {[name: string]: readonly unknown[] | string}): {
547 [outlet: string]: UrlSegmentGroup;

Callers 2

updateSegmentGroupFunction · 0.85
createNewSegmentChildrenFunction · 0.85

Calls 5

isCommandWithOutletsFunction · 0.85
createNewSegmentChildrenFunction · 0.85
isMatrixParamsFunction · 0.85
stringifyFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…