88
99import { EnvironmentInjector , Type , ɵRuntimeError as RuntimeError } from '@angular/core' ;
1010import { from , Observable , of } from 'rxjs' ;
11- import { catchError , concatMap , defaultIfEmpty , first , last as rxjsLast , map , mergeMap , scan , switchMap , tap } from 'rxjs/operators' ;
11+ import { catchError , concatMap , defaultIfEmpty , first , last , map , mergeMap , scan , switchMap , tap } from 'rxjs/operators' ;
1212
1313import { AbsoluteRedirect , ApplyRedirects , canLoadFails , noMatch , NoMatch } from './apply_redirects' ;
1414import { createUrlTreeFromSnapshot } from './create_url_tree' ;
@@ -19,9 +19,8 @@ import {RouterConfigLoader} from './router_config_loader';
1919import { ActivatedRouteSnapshot , getInherited , ParamsInheritanceStrategy , RouterStateSnapshot } from './router_state' ;
2020import { PRIMARY_OUTLET } from './shared' ;
2121import { UrlSegment , UrlSegmentGroup , UrlSerializer , UrlTree } from './url_tree' ;
22- import { last } from './utils/collection' ;
2322import { getOutlet , sortByMatchingOutlets } from './utils/config' ;
24- import { isImmediateMatch , match , MatchResult , matchWithChecks , noLeftoversInUrl , split } from './utils/config_matching' ;
23+ import { isImmediateMatch , match , matchWithChecks , noLeftoversInUrl , split } from './utils/config_matching' ;
2524import { TreeNode } from './utils/tree' ;
2625import { isEmptyError } from './utils/type_guards' ;
2726
@@ -162,7 +161,7 @@ export class Recognizer {
162161 return children ;
163162 } ) ,
164163 defaultIfEmpty ( null as TreeNode < ActivatedRouteSnapshot > [ ] | null ) ,
165- rxjsLast ( ) ,
164+ last ( ) ,
166165 mergeMap ( children => {
167166 if ( children === null ) return noMatch ( segmentGroup ) ;
168167 // Because we may have matched two outlets to the same empty path segment, we can have
@@ -235,8 +234,7 @@ export class Recognizer {
235234 consumedSegments,
236235 positionalParamSegments,
237236 remainingSegments,
238- } = route . path === '**' ? createWildcardMatchResult ( segments ) :
239- match ( segmentGroup , route , segments ) ;
237+ } = match ( segmentGroup , route , segments ) ;
240238 if ( ! matched ) return noMatch ( segmentGroup ) ;
241239
242240 // TODO(atscott): Move all of this under an if(ngDevMode) as a breaking change and allow stack
@@ -268,17 +266,13 @@ export class Recognizer {
268266 matchSegmentAgainstRoute (
269267 injector : EnvironmentInjector , rawSegment : UrlSegmentGroup , route : Route ,
270268 segments : UrlSegment [ ] , outlet : string ) : Observable < TreeNode < ActivatedRouteSnapshot > > {
271- let matchResult : Observable < MatchResult > ;
272-
269+ const matchResult = matchWithChecks ( rawSegment , route , segments , injector , this . urlSerializer ) ;
273270 if ( route . path === '**' ) {
274- matchResult = of ( createWildcardMatchResult ( segments ) ) ;
275271 // Prior versions of the route matching algorithm would stop matching at the wildcard route.
276272 // We should investigate a better strategy for any existing children. Otherwise, these
277273 // child segments are silently dropped from the navigation.
278274 // https://github.com/angular/angular/issues/40089
279275 rawSegment . children = { } ;
280- } else {
281- matchResult = matchWithChecks ( rawSegment , route , segments , injector , this . urlSerializer ) ;
282276 }
283277
284278 return matchResult . pipe ( switchMap ( ( result ) => {
@@ -437,13 +431,3 @@ function getData(route: Route): Data {
437431function getResolve ( route : Route ) : ResolveData {
438432 return route . resolve || { } ;
439433}
440-
441- function createWildcardMatchResult ( segments : UrlSegment [ ] ) : MatchResult {
442- return {
443- matched : true ,
444- parameters : segments . length > 0 ? last ( segments ) ! . parameters : { } ,
445- consumedSegments : segments ,
446- remainingSegments : [ ] ,
447- positionalParamSegments : { } ,
448- } ;
449- }
0 commit comments