MCPcopy
hub / github.com/angular/angular / createUrlTreeFromSegmentGroup

Function createUrlTreeFromSegmentGroup

packages/router/src/create_url_tree.ts:119–148  ·  view source on GitHub ↗
(
  relativeTo: UrlSegmentGroup,
  commands: readonly any[],
  queryParams: Params | null,
  fragment: string | null,
  urlSerializer: UrlSerializer,
)

Source from the content-addressed store, hash-verified

117}
118
119export function createUrlTreeFromSegmentGroup(
120 relativeTo: UrlSegmentGroup,
121 commands: readonly any[],
122 queryParams: Params | null,
123 fragment: string | null,
124 urlSerializer: UrlSerializer,
125): UrlTree {
126 let root = relativeTo;
127 while (root.parent) {
128 root = root.parent;
129 }
130 // There are no commands so the `UrlTree` goes to the same path as the one created from the
131 // `UrlSegmentGroup`. All we need to do is update the `queryParams` and `fragment` without
132 // applying any other logic.
133 if (commands.length === 0) {
134 return tree(root, root, root, queryParams, fragment, urlSerializer);
135 }
136
137 const nav = computeNavigation(commands);
138
139 if (nav.toRoot()) {
140 return tree(root, root, new UrlSegmentGroup([], {}), queryParams, fragment, urlSerializer);
141 }
142
143 const position = findStartingPositionForTargetGroup(nav, root, relativeTo);
144 const newSegmentGroup = position.processChildren
145 ? updateSegmentGroupChildren(position.segmentGroup, position.index, nav.commands)
146 : updateSegmentGroup(position.segmentGroup, position.index, nav.commands);
147 return tree(root, position.segmentGroup, newSegmentGroup, queryParams, fragment, urlSerializer);
148}
149
150function isMatrixParams(command: any): boolean {
151 return typeof command === 'object' && command != null && !command.outlets && !command.segmentPath;

Callers 2

createUrlTreeMethod · 0.90

Calls 6

computeNavigationFunction · 0.85
updateSegmentGroupFunction · 0.85
toRootMethod · 0.80
treeFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…