@@ -15,7 +15,8 @@ import {createRouterState} from './create_router_state';
1515import { createUrlTree } from './create_url_tree' ;
1616import { RuntimeErrorCode } from './errors' ;
1717import { Event , GuardsCheckEnd , GuardsCheckStart , NavigationCancel , NavigationCancellationCode , NavigationEnd , NavigationError , NavigationStart , NavigationTrigger , ResolveEnd , ResolveStart , RouteConfigLoadEnd , RouteConfigLoadStart , RoutesRecognized } from './events' ;
18- import { QueryParamsHandling , Route , Routes } from './models' ;
18+ import { NavigationBehaviorOptions , QueryParamsHandling , Route , Routes } from './models' ;
19+ import { isNavigationCancelingError , isRedirectingNavigationCancelingError , redirectingNavigationError } from './navigation_canceling_error' ;
1920import { activateRoutes } from './operators/activate_routes' ;
2021import { applyRedirects } from './operators/apply_redirects' ;
2122import { checkGuards } from './operators/check_guards' ;
@@ -27,12 +28,11 @@ import {DefaultRouteReuseStrategy, RouteReuseStrategy} from './route_reuse_strat
2728import { RouterConfigLoader } from './router_config_loader' ;
2829import { ChildrenOutletContexts } from './router_outlet_context' ;
2930import { ActivatedRoute , ActivatedRouteSnapshot , createEmptyState , RouterState , RouterStateSnapshot } from './router_state' ;
30- import { isNavigationCancelingError , navigationCancelingError , Params , REDIRECTING_CANCELLATION_REASON } from './shared' ;
31+ import { Params } from './shared' ;
3132import { DefaultUrlHandlingStrategy , UrlHandlingStrategy } from './url_handling_strategy' ;
32- import { containsTree , createEmptyUrlTree , IsActiveMatchOptions , UrlSerializer , UrlTree } from './url_tree' ;
33+ import { containsTree , createEmptyUrlTree , IsActiveMatchOptions , isUrlTree , UrlSerializer , UrlTree } from './url_tree' ;
3334import { standardizeConfig , validateConfig } from './utils/config' ;
3435import { Checks , getAllRouteGuards } from './utils/preactivation' ;
35- import { isUrlTree } from './utils/type_guards' ;
3636
3737
3838const NG_DEV_MODE = typeof ngDevMode === 'undefined' || ! ! ngDevMode ;
@@ -145,58 +145,6 @@ export interface UrlCreationOptions {
145145 preserveFragment ?: boolean ;
146146}
147147
148- /**
149- * @description
150- *
151- * Options that modify the `Router` navigation strategy.
152- * Supply an object containing any of these properties to a `Router` navigation function to
153- * control how the navigation should be handled.
154- *
155- * @see [Router.navigate() method](api/router/Router#navigate)
156- * @see [Router.navigateByUrl() method](api/router/Router#navigatebyurl)
157- * @see [Routing and Navigation guide](guide/router)
158- *
159- * @publicApi
160- */
161- export interface NavigationBehaviorOptions {
162- /**
163- * When true, navigates without pushing a new state into history.
164- *
165- * ```
166- * // Navigate silently to /view
167- * this.router.navigate(['/view'], { skipLocationChange: true });
168- * ```
169- */
170- skipLocationChange ?: boolean ;
171-
172- /**
173- * When true, navigates while replacing the current state in history.
174- *
175- * ```
176- * // Navigate to /view
177- * this.router.navigate(['/view'], { replaceUrl: true });
178- * ```
179- */
180- replaceUrl ?: boolean ;
181-
182- /**
183- * Developer-defined state that can be passed to any navigation.
184- * Access this value through the `Navigation.extras` object
185- * returned from the [Router.getCurrentNavigation()
186- * method](api/router/Router#getcurrentnavigation) while a navigation is executing.
187- *
188- * After a navigation completes, the router writes an object containing this
189- * value together with a `navigationId` to `history.state`.
190- * The value is written when `location.go()` or `location.replaceState()`
191- * is called before activating this route.
192- *
193- * Note that `history.state` does not pass an object equality test because
194- * the router adds the `navigationId` on each navigation.
195- *
196- */
197- state ?: { [ k : string ] : any } ;
198- }
199-
200148/**
201149 * @description
202150 *
@@ -761,11 +709,7 @@ export class Router {
761709 checkGuards ( this . ngModule . injector , ( evt : Event ) => this . triggerEvent ( evt ) ) ,
762710 tap ( t => {
763711 if ( isUrlTree ( t . guardsResult ) ) {
764- throw navigationCancelingError (
765- NG_DEV_MODE &&
766- REDIRECTING_CANCELLATION_REASON +
767- `"${ this . serializeUrl ( t . guardsResult ) } "` ,
768- NavigationCancellationCode . Redirect , t . guardsResult ) ;
712+ throw redirectingNavigationError ( this . urlSerializer , t . guardsResult ) ;
769713 }
770714
771715 const guardsEnd = new GuardsCheckEnd (
@@ -929,8 +873,7 @@ export class Router {
929873 /* This error type is issued during Redirect, and is handled as a
930874 * cancellation rather than an error. */
931875 if ( isNavigationCancelingError ( e ) ) {
932- const redirecting = isUrlTree ( e . url ) ;
933- if ( ! redirecting ) {
876+ if ( ! isRedirectingNavigationCancelingError ( e ) ) {
934877 // Set property only if we're not redirecting. If we landed on a page and
935878 // redirect to `/` route, the new navigation is going to see the `/`
936879 // isn't a change from the default currentUrlTree and won't navigate.
@@ -946,7 +889,7 @@ export class Router {
946889
947890 // When redirecting, we need to delay resolving the navigation
948891 // promise and push it to the redirect navigation
949- if ( ! isUrlTree ( e . url ) ) {
892+ if ( ! isRedirectingNavigationCancelingError ( e ) ) {
950893 t . resolve ( false ) ;
951894 } else {
952895 const mergedTree =
0 commit comments