* Replaces the `oldSegment` which is located in some child of the `current` with the `newSegment`. * This also has the effect of creating new `UrlSegmentGroup` copies to update references. This * shouldn't be necessary but the fallback logic for an invalid ActivatedRoute in the creation uses * th
( current: UrlSegmentGroup, oldSegment: UrlSegmentGroup, newSegment: UrlSegmentGroup, )
| 221 | * value. |
| 222 | */ |
| 223 | function replaceSegment( |
| 224 | current: UrlSegmentGroup, |
| 225 | oldSegment: UrlSegmentGroup, |
| 226 | newSegment: UrlSegmentGroup, |
| 227 | ): UrlSegmentGroup { |
| 228 | const children: {[key: string]: UrlSegmentGroup} = {}; |
| 229 | Object.entries(current.children).forEach(([outletName, c]) => { |
| 230 | if (c === oldSegment) { |
| 231 | children[outletName] = newSegment; |
| 232 | } else { |
| 233 | children[outletName] = replaceSegment(c, oldSegment, newSegment); |
| 234 | } |
| 235 | }); |
| 236 | return new UrlSegmentGroup(current.segments, children); |
| 237 | } |
| 238 | |
| 239 | class Navigation { |
| 240 | constructor( |