@@ -16,9 +16,8 @@ import {navigationCancelingError} from './navigation_canceling_error';
1616import { Params , PRIMARY_OUTLET } from './shared' ;
1717import { UrlSegment , UrlSegmentGroup , UrlSerializer , UrlTree } from './url_tree' ;
1818
19-
2019export class NoMatch {
21- public segmentGroup : UrlSegmentGroup | null ;
20+ public segmentGroup : UrlSegmentGroup | null ;
2221
2322 constructor ( segmentGroup ?: UrlSegmentGroup ) {
2423 this . segmentGroup = segmentGroup || null ;
@@ -40,23 +39,30 @@ export function absoluteRedirect(newTree: UrlTree): Observable<any> {
4039}
4140
4241export function namedOutletsRedirect ( redirectTo : string ) : Observable < any > {
43- return throwError ( new RuntimeError (
42+ return throwError (
43+ new RuntimeError (
4444 RuntimeErrorCode . NAMED_OUTLET_REDIRECT ,
4545 ( typeof ngDevMode === 'undefined' || ngDevMode ) &&
46- `Only absolute redirects can have named outlets. redirectTo: '${ redirectTo } '` ) ) ;
46+ `Only absolute redirects can have named outlets. redirectTo: '${ redirectTo } '` ,
47+ ) ,
48+ ) ;
4749}
4850
4951export function canLoadFails ( route : Route ) : Observable < LoadedRouterConfig > {
50- return throwError ( navigationCancelingError (
52+ return throwError (
53+ navigationCancelingError (
5154 ( typeof ngDevMode === 'undefined' || ngDevMode ) &&
52- `Cannot load children because the guard of the route "path: '${
53- route . path } '" returned false`,
54- NavigationCancellationCode . GuardRejected ) ) ;
55+ `Cannot load children because the guard of the route "path: '${ route . path } '" returned false` ,
56+ NavigationCancellationCode . GuardRejected ,
57+ ) ,
58+ ) ;
5559}
5660
57-
5861export class ApplyRedirects {
59- constructor ( private urlSerializer : UrlSerializer , private urlTree : UrlTree ) { }
62+ constructor (
63+ private urlSerializer : UrlSerializer ,
64+ private urlTree : UrlTree ,
65+ ) { }
6066
6167 lineralizeSegments ( route : Route , urlTree : UrlTree ) : Observable < UrlSegment [ ] > {
6268 let res : UrlSegment [ ] = [ ] ;
@@ -76,22 +82,34 @@ export class ApplyRedirects {
7682 }
7783
7884 applyRedirectCommands (
79- segments : UrlSegment [ ] , redirectTo : string , posParams : { [ k : string ] : UrlSegment } ) : UrlTree {
85+ segments : UrlSegment [ ] ,
86+ redirectTo : string ,
87+ posParams : { [ k : string ] : UrlSegment } ,
88+ ) : UrlTree {
8089 const newTree = this . applyRedirectCreateUrlTree (
81- redirectTo , this . urlSerializer . parse ( redirectTo ) , segments , posParams ) ;
90+ redirectTo ,
91+ this . urlSerializer . parse ( redirectTo ) ,
92+ segments ,
93+ posParams ,
94+ ) ;
8295 if ( redirectTo . startsWith ( '/' ) ) {
8396 throw new AbsoluteRedirect ( newTree ) ;
8497 }
8598 return newTree ;
8699 }
87100
88101 applyRedirectCreateUrlTree (
89- redirectTo : string , urlTree : UrlTree , segments : UrlSegment [ ] ,
90- posParams : { [ k : string ] : UrlSegment } ) : UrlTree {
102+ redirectTo : string ,
103+ urlTree : UrlTree ,
104+ segments : UrlSegment [ ] ,
105+ posParams : { [ k : string ] : UrlSegment } ,
106+ ) : UrlTree {
91107 const newRoot = this . createSegmentGroup ( redirectTo , urlTree . root , segments , posParams ) ;
92108 return new UrlTree (
93- newRoot , this . createQueryParams ( urlTree . queryParams , this . urlTree . queryParams ) ,
94- urlTree . fragment ) ;
109+ newRoot ,
110+ this . createQueryParams ( urlTree . queryParams , this . urlTree . queryParams ) ,
111+ urlTree . fragment ,
112+ ) ;
95113 }
96114
97115 createQueryParams ( redirectToParams : Params , actualParams : Params ) : Params {
@@ -109,8 +127,11 @@ export class ApplyRedirects {
109127 }
110128
111129 createSegmentGroup (
112- redirectTo : string , group : UrlSegmentGroup , segments : UrlSegment [ ] ,
113- posParams : { [ k : string ] : UrlSegment } ) : UrlSegmentGroup {
130+ redirectTo : string ,
131+ group : UrlSegmentGroup ,
132+ segments : UrlSegment [ ] ,
133+ posParams : { [ k : string ] : UrlSegment } ,
134+ ) : UrlSegmentGroup {
114135 const updatedSegments = this . createSegments ( redirectTo , group . segments , segments , posParams ) ;
115136
116137 let children : { [ n : string ] : UrlSegmentGroup } = { } ;
@@ -122,22 +143,30 @@ export class ApplyRedirects {
122143 }
123144
124145 createSegments (
125- redirectTo : string , redirectToSegments : UrlSegment [ ] , actualSegments : UrlSegment [ ] ,
126- posParams : { [ k : string ] : UrlSegment } ) : UrlSegment [ ] {
127- return redirectToSegments . map (
128- s => s . path . startsWith ( ':' ) ? this . findPosParam ( redirectTo , s , posParams ) :
129- this . findOrReturn ( s , actualSegments ) ) ;
146+ redirectTo : string ,
147+ redirectToSegments : UrlSegment [ ] ,
148+ actualSegments : UrlSegment [ ] ,
149+ posParams : { [ k : string ] : UrlSegment } ,
150+ ) : UrlSegment [ ] {
151+ return redirectToSegments . map ( ( s ) =>
152+ s . path . startsWith ( ':' )
153+ ? this . findPosParam ( redirectTo , s , posParams )
154+ : this . findOrReturn ( s , actualSegments ) ,
155+ ) ;
130156 }
131157
132158 findPosParam (
133- redirectTo : string , redirectToUrlSegment : UrlSegment ,
134- posParams : { [ k : string ] : UrlSegment } ) : UrlSegment {
159+ redirectTo : string ,
160+ redirectToUrlSegment : UrlSegment ,
161+ posParams : { [ k : string ] : UrlSegment } ,
162+ ) : UrlSegment {
135163 const pos = posParams [ redirectToUrlSegment . path . substring ( 1 ) ] ;
136164 if ( ! pos )
137165 throw new RuntimeError (
138- RuntimeErrorCode . MISSING_REDIRECT ,
139- ( typeof ngDevMode === 'undefined' || ngDevMode ) &&
140- `Cannot redirect to '${ redirectTo } '. Cannot find '${ redirectToUrlSegment . path } '.` ) ;
166+ RuntimeErrorCode . MISSING_REDIRECT ,
167+ ( typeof ngDevMode === 'undefined' || ngDevMode ) &&
168+ `Cannot redirect to '${ redirectTo } '. Cannot find '${ redirectToUrlSegment . path } '.` ,
169+ ) ;
141170 return pos ;
142171 }
143172
0 commit comments