( relativeTo: UrlSegmentGroup, commands: readonly any[], queryParams: Params | null, fragment: string | null, urlSerializer: UrlSerializer, )
| 117 | } |
| 118 | |
| 119 | export 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 | |
| 150 | function isMatrixParams(command: any): boolean { |
| 151 | return typeof command === 'object' && command != null && !command.outlets && !command.segmentPath; |
no test coverage detected
searching dependent graphs…