MCPcopy Index your code
hub / github.com/angular/angular / replaceSegment

Function replaceSegment

packages/router/src/create_url_tree.ts:223–237  ·  view source on GitHub ↗

* 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,
)

Source from the content-addressed store, hash-verified

221 * value.
222 */
223function 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
239class Navigation {
240 constructor(

Callers 1

treeFunction · 0.85

Calls 2

forEachMethod · 0.45
entriesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…