MCPcopy Create free account
hub / github.com/angular/angular / matchWithChecks

Function matchWithChecks

packages/router/src/utils/config_matching.ts:54–81  ·  view source on GitHub ↗
(
  segmentGroup: UrlSegmentGroup,
  route: Route,
  segments: UrlSegment[],
  injector: EnvironmentInjector,
  urlSerializer: UrlSerializer,
  createSnapshot: (result: MatchResult) => ActivatedRouteSnapshot,
  abortSignal: AbortSignal,
)

Source from the content-addressed store, hash-verified

52}
53
54export function matchWithChecks(
55 segmentGroup: UrlSegmentGroup,
56 route: Route,
57 segments: UrlSegment[],
58 injector: EnvironmentInjector,
59 urlSerializer: UrlSerializer,
60 createSnapshot: (result: MatchResult) => ActivatedRouteSnapshot,
61 abortSignal: AbortSignal,
62): Observable<MatchResult> {
63 const result = match(segmentGroup, route, segments);
64 if (!result.matched) {
65 return of(result);
66 }
67
68 const currentSnapshot = createPreMatchRouteSnapshot(createSnapshot(result));
69 // Only create the Route's `EnvironmentInjector` if it matches the attempted
70 // navigation
71 // TODO(v23): Run canMatch guards in root environment injector in 3p as well.
72 injector = getOrCreateRouteInjectorIfNeeded(route, injector); // 3p-only
73 return runCanMatchGuards(
74 injector,
75 route,
76 segments,
77 urlSerializer,
78 currentSnapshot,
79 abortSignal,
80 ).pipe(map((v) => (v === true ? result : {...noMatch})));
81}
82
83export function match(
84 segmentGroup: UrlSegmentGroup,

Callers 1

Calls 5

runCanMatchGuardsFunction · 0.90
matchFunction · 0.85
createSnapshotFunction · 0.85

Tested by

no test coverage detected