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

Method match

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

Source from the content-addressed store, hash-verified

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