MCPcopy
hub / github.com/angular/angular / matchSegmentAgainstRoute

Method matchSegmentAgainstRoute

packages/router/src/recognize.ts:402–493  ·  view source on GitHub ↗
(
    injector: EnvironmentInjector,
    rawSegment: UrlSegmentGroup,
    route: Route,
    segments: UrlSegment[],
    outlet: string,
    parentRoute: ActivatedRouteSnapshot,
  )

Source from the content-addressed store, hash-verified

400 }
401
402 async matchSegmentAgainstRoute(
403 injector: EnvironmentInjector,
404 rawSegment: UrlSegmentGroup,
405 route: Route,
406 segments: UrlSegment[],
407 outlet: string,
408 parentRoute: ActivatedRouteSnapshot,
409 ): Promise<TreeNode<ActivatedRouteSnapshot>> {
410 if (this.abortSignal.aborted) {
411 throw new Error(this.abortSignal.reason);
412 }
413
414 const createSnapshot = (result: MatchResult) =>
415 this.createSnapshot(injector, route, result.consumedSegments, result.parameters, parentRoute);
416 const result = await firstValueFrom(
417 matchWithChecks(
418 rawSegment,
419 route,
420 segments,
421 injector,
422 this.urlSerializer,
423 createSnapshot,
424 this.abortSignal,
425 ),
426 );
427 if (route.path === '**') {
428 // Prior versions of the route matching algorithm would stop matching at the wildcard route.
429 // We should investigate a better strategy for any existing children. Otherwise, these
430 // child segments are silently dropped from the navigation.
431 // https://github.com/angular/angular/issues/40089
432 rawSegment.children = {};
433 }
434
435 if (!result?.matched) {
436 throw new NoMatch(rawSegment);
437 }
438 // If the route has an injector created from providers, we should start using that.
439 injector = route._injector ?? injector;
440 const {routes: childConfig} = await this.getChildConfig(injector, route, segments);
441 const childInjector = route._loadedInjector ?? injector;
442
443 const {parameters, consumedSegments, remainingSegments} = result;
444 const snapshot = this.createSnapshot(
445 injector,
446 route,
447 consumedSegments,
448 parameters,
449 parentRoute,
450 );
451
452 const {segmentGroup, slicedSegments} = split(
453 rawSegment,
454 consumedSegments,
455 remainingSegments,
456 childConfig,
457 outlet,
458 );
459

Callers 1

Calls 9

getChildConfigMethod · 0.95
createSnapshotMethod · 0.95
processChildrenMethod · 0.95
processSegmentMethod · 0.95
firstValueFromFunction · 0.90
matchWithChecksFunction · 0.90
splitFunction · 0.90
getOutletFunction · 0.90
hasChildrenMethod · 0.45

Tested by

no test coverage detected