File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,8 @@ export function fillParams (
2020 ( regexpCompileCache [ path ] = Regexp . compile ( path ) )
2121
2222 // Fix #2505 resolving asterisk routes { name: 'not-found', params: { pathMatch: '/not-found' }}
23- if ( params . pathMatch ) params [ 0 ] = params . pathMatch
23+ // and fix #3106 so that you can work with location descriptor object having params.pathMatch equal to empty string
24+ if ( typeof params . pathMatch === 'string' ) params [ 0 ] = params . pathMatch
2425
2526 return filler ( params , { pretty : true } )
2627 } catch ( e ) {
Original file line number Diff line number Diff line change @@ -84,4 +84,20 @@ describe('Creating Matcher', function () {
8484 const { params } = match ( { path : '/not-found' } , routes [ 0 ] )
8585 expect ( params ) . toEqual ( { pathMatch : '/not-found' } )
8686 } )
87+
88+ it ( 'allows an empty pathMatch' , function ( ) {
89+ process . env . NODE_ENV = 'development'
90+ const pathForErrorRoute = match (
91+ { name : 'error' , params : { pathMatch : '' } } ,
92+ routes [ 0 ]
93+ ) . path
94+ const pathForNotFoundRoute = match (
95+ { name : 'notFound' , params : { pathMatch : '' } } ,
96+ routes [ 0 ]
97+ ) . path
98+
99+ expect ( console . warn ) . not . toHaveBeenCalled ( )
100+ expect ( pathForErrorRoute ) . toEqual ( '/error/' )
101+ expect ( pathForNotFoundRoute ) . toEqual ( '/' )
102+ } )
87103} )
You can’t perform that action at this time.
0 commit comments