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

Method match

packages/router/src/recognize.ts:125–171  ·  view source on GitHub ↗
(rootSegmentGroup: UrlSegmentGroup)

Source from the content-addressed store, hash-verified

123 }
124
125 private async match(rootSegmentGroup: UrlSegmentGroup): Promise<{
126 children: TreeNode<ActivatedRouteSnapshot>[];
127 rootSnapshot: ActivatedRouteSnapshot;
128 }> {
129 // Use Object.freeze to prevent readers of the Router state from modifying it outside
130 // of a navigation, resulting in the router being out of sync with the browser.
131 const rootSnapshot = new ActivatedRouteSnapshot(
132 [],
133 Object.freeze({}),
134 this.queryParams,
135 this.urlTree.fragment,
136 Object.freeze({}),
137 PRIMARY_OUTLET,
138 this.rootComponentType,
139 null,
140 {},
141 this.injector,
142 );
143 const children = await this.processSegmentGroup(
144 this.injector,
145 this.config,
146 rootSegmentGroup,
147 PRIMARY_OUTLET,
148 rootSnapshot,
149 );
150 if (children instanceof AbsoluteRedirect) {
151 // Count at the actual root-restart boundary so redirects returned from functions are
152 // subject to the same limit as static redirects.
153 this.absoluteRedirectCount++;
154 if (this.absoluteRedirectCount > MAX_ALLOWED_REDIRECTS) {
155 if (ngDevMode) {
156 throw new RuntimeError(
157 RuntimeErrorCode.INFINITE_REDIRECT,
158 `Detected possible infinite redirect when redirecting from '${this.urlTree}' to '${children.urlTree}'.`,
159 );
160 }
161 this.allowRedirects = false;
162 }
163 this.urlTree = children.urlTree;
164 this.queryParams = Object.freeze({...this.urlTree.queryParams});
165 return this.match(children.urlTree.root);
166 }
167 if (children instanceof NoMatch) {
168 throw this.noMatchError(children);
169 }
170 return {children, rootSnapshot};
171 }
172
173 async processSegmentGroup(
174 injector: EnvironmentInjector,

Callers 15

recognizeMethod · 0.95
_aggregateEventsMethod · 0.45
normalizeEventFunction · 0.45
getAppContentsFunction · 0.45
getFirstClassDeclarationFunction · 0.45
matchSegmentsFunction · 0.45
matchMatrixKeySegmentsFunction · 0.45
matchQueryParamsFunction · 0.45
matchUrlQueryParamValueFunction · 0.45
getDirectiveRequireMethod · 0.45

Calls 2

processSegmentGroupMethod · 0.95
noMatchErrorMethod · 0.95

Tested by

no test coverage detected