@@ -314,19 +314,23 @@ describe('Router', () => {
314314 expect ( route2 . path ) . toBe ( '/optional' )
315315 expect ( route2 . params ) . toEqual ( { } )
316316
317- // but keeps empty strings
318- const route3 = router . resolve ( {
319- name : 'optional' ,
320- params : { p : '' } ,
321- } )
322- expect ( route3 . path ) . toBe ( '/optional' )
323- expect ( route3 . params ) . toEqual ( { p : '' } )
324-
325317 await router . push ( { name : 'optional' , params : { p : null } } )
326318 expect ( router . currentRoute . value . params ) . toEqual ( { } )
327319 await router . push ( { name : 'optional' , params : { } } )
328320 } )
329321
322+ it ( 'removes null/undefined params when current location has it' , async ( ) => {
323+ const { router } = await newRouter ( )
324+
325+ await router . push ( { name : 'optional' , params : { p : 'a' } } )
326+ await router . push ( { name : 'optional' , params : { p : null } } )
327+ expect ( router . currentRoute . value . params ) . toEqual ( { } )
328+
329+ await router . push ( { name : 'optional' , params : { p : 'a' } } )
330+ await router . push ( { name : 'optional' , params : { p : undefined } } )
331+ expect ( router . currentRoute . value . params ) . toEqual ( { } )
332+ } )
333+
330334 it ( 'keeps empty strings' , async ( ) => {
331335 const { router } = await newRouter ( )
332336 const route1 = router . resolve ( { name : 'optional' , params : { p : '' } } )
0 commit comments