forked from EVOgeek/Vmeda.Online
		
	MOBILE-3320 course: Fix regex patch matcher
This commit is contained in:
		
							parent
							
								
									ae74cdb91f
								
							
						
					
					
						commit
						81876ca518
					
				| @ -17,7 +17,7 @@ import { UrlSegment, UrlSegmentGroup } from '@angular/router'; | |||||||
| 
 | 
 | ||||||
| import { mock } from '@/testing/utils'; | import { mock } from '@/testing/utils'; | ||||||
| 
 | 
 | ||||||
| import { buildRegExpUrlMatcher } from '../app-routing.module'; | import { buildRegExpUrlMatcher } from './app-routing.module'; | ||||||
| 
 | 
 | ||||||
| describe('Routing utils', () => { | describe('Routing utils', () => { | ||||||
| 
 | 
 | ||||||
| @ -35,6 +35,7 @@ describe('Routing utils', () => { | |||||||
|                 ); |                 ); | ||||||
| 
 | 
 | ||||||
|         testMatcher('baz/foo/bar', null); |         testMatcher('baz/foo/bar', null); | ||||||
|  |         testMatcher('foobar', null); | ||||||
|         testMatcher('foo', ['foo']); |         testMatcher('foo', ['foo']); | ||||||
|         testMatcher('foo/baz', ['foo']); |         testMatcher('foo/baz', ['foo']); | ||||||
|         testMatcher('foo/bar/bar/baz', ['foo', 'bar', 'bar']); |         testMatcher('foo/bar/bar/baz', ['foo', 'bar', 'bar']); | ||||||
| @ -113,14 +113,18 @@ export function buildRegExpUrlMatcher(regexp: RegExp): UrlMatcher { | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // Consume segments that match.
 |         // Consume segments that match.
 | ||||||
|         const [consumed] = segments.slice(1).reduce(([consumed, path], segment) => path === match |         const [consumedSegments, consumedPath] = segments.slice(1).reduce(([segments, path], segment) => path === match | ||||||
|             ? [consumed, path] |             ? [segments, path] | ||||||
|             :[ |             : [ | ||||||
|                 consumed.concat(segment), |                 segments.concat(segment), | ||||||
|                 `${path}/${segment.path}`, |                 `${path}/${segment.path}`, | ||||||
|             ], [[segments[0]] as UrlSegment[], segments[0].path]); |             ], [[segments[0]] as UrlSegment[], segments[0].path]); | ||||||
| 
 | 
 | ||||||
|         return { consumed }; |         if (consumedPath !== match) { | ||||||
|  |             return null; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return { consumed: consumedSegments }; | ||||||
|     }; |     }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user