Skip to content

Commit 57794f0

Browse files
AndrewKushnirmmalerba
authored andcommitted
Revert "refactor(router): produce error message when canMatch is used with redirectTo (angular#60958)" (angular#60989)
This reverts commit 907f9bd. PR Close angular#60989
1 parent 3331b10 commit 57794f0

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

packages/router/src/utils/config.ts

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -141,29 +141,25 @@ function validateNode(route: Route, fullPath: string, requireStandaloneComponent
141141
`Invalid configuration of route '${fullPath}': children and loadChildren cannot be used together`,
142142
);
143143
}
144+
if (route.redirectTo && (route.component || route.loadComponent)) {
145+
throw new RuntimeError(
146+
RuntimeErrorCode.INVALID_ROUTE_CONFIG,
147+
`Invalid configuration of route '${fullPath}': redirectTo and component/loadComponent cannot be used together`,
148+
);
149+
}
144150
if (route.component && route.loadComponent) {
145151
throw new RuntimeError(
146152
RuntimeErrorCode.INVALID_ROUTE_CONFIG,
147153
`Invalid configuration of route '${fullPath}': component and loadComponent cannot be used together`,
148154
);
149155
}
150-
151-
if (route.redirectTo) {
152-
if (route.component || route.loadComponent) {
153-
throw new RuntimeError(
154-
RuntimeErrorCode.INVALID_ROUTE_CONFIG,
155-
`Invalid configuration of route '${fullPath}': redirectTo and component/loadComponent cannot be used together`,
156-
);
157-
}
158-
if (route.canMatch || route.canActivate) {
159-
throw new RuntimeError(
160-
RuntimeErrorCode.INVALID_ROUTE_CONFIG,
161-
`Invalid configuration of route '${fullPath}': redirectTo and ${route.canMatch ? 'canMatch' : 'canActivate'} cannot be used together.` +
162-
`Redirects happen before guards are executed.`,
163-
);
164-
}
156+
if (route.redirectTo && route.canActivate) {
157+
throw new RuntimeError(
158+
RuntimeErrorCode.INVALID_ROUTE_CONFIG,
159+
`Invalid configuration of route '${fullPath}': redirectTo and canActivate cannot be used together. Redirects happen before activation ` +
160+
`so canActivate will never be executed.`,
161+
);
165162
}
166-
167163
if (route.path && route.matcher) {
168164
throw new RuntimeError(
169165
RuntimeErrorCode.INVALID_ROUTE_CONFIG,

0 commit comments

Comments
 (0)