(
injector: EnvironmentInjector,
rawSegment: UrlSegmentGroup,
route: Route,
segments: UrlSegment[],
outlet: string,
parentRoute: ActivatedRouteSnapshot,
)
| 419 | } |
| 420 | |
| 421 | async matchSegmentAgainstRoute( |
| 422 | injector: EnvironmentInjector, |
| 423 | rawSegment: UrlSegmentGroup, |
| 424 | route: Route, |
| 425 | segments: UrlSegment[], |
| 426 | outlet: string, |
| 427 | parentRoute: ActivatedRouteSnapshot, |
| 428 | ): Promise<TreeNode<ActivatedRouteSnapshot> | NoMatch | AbsoluteRedirect> { |
| 429 | if (this.abortSignal.aborted) { |
| 430 | throw new Error(this.abortSignal.reason); |
| 431 | } |
| 432 | |
| 433 | const createSnapshot = (result: MatchResult) => |
| 434 | this.createSnapshot(injector, route, result.consumedSegments, result.parameters, parentRoute); |
| 435 | const result = await firstValueFrom( |
| 436 | matchWithChecks( |
| 437 | rawSegment, |
| 438 | route, |
| 439 | segments, |
| 440 | // TODO(v23): Run canMatch guards in root environment injector in 3p as well. |
| 441 | // g3-only this.injector, |
| 442 | injector, // 3p-only |
| 443 | this.urlSerializer, |
| 444 | createSnapshot, |
| 445 | this.abortSignal, |
| 446 | ), |
| 447 | ); |
| 448 | if (route.path === '**') { |
| 449 | // Prior versions of the route matching algorithm would stop matching at the wildcard route. |
| 450 | // We should investigate a better strategy for any existing children. Otherwise, these |
| 451 | // child segments are silently dropped from the navigation. |
| 452 | // https://github.com/angular/angular/issues/40089 |
| 453 | rawSegment.children = {}; |
| 454 | } |
| 455 | |
| 456 | if (!result?.matched) { |
| 457 | return new NoMatch(); |
| 458 | } |
| 459 | // If the route has an injector created from providers, we should start using that. |
| 460 | injector = getOrCreateRouteInjectorIfNeeded(route, injector); |
| 461 | const {routes: childConfig} = await this.getChildConfig(injector, route, segments); |
| 462 | const childInjector = route._loadedInjector ?? injector; |
| 463 | |
| 464 | const {parameters, consumedSegments, remainingSegments} = result; |
| 465 | const snapshot = this.createSnapshot( |
| 466 | injector, |
| 467 | route, |
| 468 | consumedSegments, |
| 469 | parameters, |
| 470 | parentRoute, |
| 471 | ); |
| 472 | |
| 473 | const matchedOnOutlet = getOutlet(route) === outlet; |
| 474 | const {segmentGroup, slicedSegments} = matchedOnOutlet |
| 475 | ? split(rawSegment, consumedSegments, remainingSegments, childConfig) |
| 476 | : {segmentGroup: rawSegment, slicedSegments: remainingSegments}; |
| 477 | |
| 478 | if (matchedOnOutlet && slicedSegments.length === 0 && segmentGroup.hasChildren()) { |
no test coverage detected