File tree Expand file tree Collapse file tree 2 files changed +22
-22
lines changed Expand file tree Collapse file tree 2 files changed +22
-22
lines changed Original file line number Diff line number Diff line change @@ -534,16 +534,22 @@ describe('Router', () => {
534534 } )
535535 } )
536536
537- // https://github.com/vuejs/router/issues/2187
538- it ( 'keeps a consistent value on fullPath when resolving' , async ( ) => {
537+ it ( 'should be able to resolve a partially updated location' , async ( ) => {
539538 const { router } = await newRouter ( )
540- const targetLoc = '/search#/?redirect=%2F%3Fid%3D1%23%2Fabc'
541- expect ( router . resolve ( targetLoc ) . fullPath ) . toBe ( targetLoc )
542- await router . push ( targetLoc )
543- expect ( router . currentRoute . value . fullPath ) . toBe ( targetLoc )
544- await router . push ( '/' )
545- await router . replace ( targetLoc )
546- expect ( router . currentRoute . value . fullPath ) . toBe ( targetLoc )
539+ expect (
540+ router . resolve ( {
541+ // spread the current location
542+ ...router . currentRoute . value ,
543+ // then update some stuff, creating inconsistencies,
544+ query : { a : '1' } ,
545+ hash : '#a' ,
546+ } )
547+ ) . toMatchObject ( {
548+ query : { a : '1' } ,
549+ path : '/' ,
550+ fullPath : '/?a=1#a' ,
551+ hash : '#a' ,
552+ } )
547553 } )
548554
549555 describe ( 'navigation cancelled' , ( ) => {
Original file line number Diff line number Diff line change @@ -525,19 +525,13 @@ export function createRouter(options: RouterOptions): Router {
525525 // we need to run the decoding again
526526 matchedRoute . params = normalizeParams ( decodeParams ( matchedRoute . params ) )
527527
528- const fullPath =
529- // @ts -expect-error: the rawLocation doesn't normally have a fullPath
530- // but sometimes it gets noramlized before being passed to resolve and we can
531- // resue it to avoid encoding an unencoded path from the user in order to be closer
532- // to the URL constructor behavior. vuejs/router#2187
533- rawLocation . fullPath ||
534- stringifyURL (
535- stringifyQuery ,
536- assign ( { } , rawLocation , {
537- hash : encodeHash ( hash ) ,
538- path : matchedRoute . path ,
539- } )
540- )
528+ const fullPath = stringifyURL (
529+ stringifyQuery ,
530+ assign ( { } , rawLocation , {
531+ hash : encodeHash ( hash ) ,
532+ path : matchedRoute . path ,
533+ } )
534+ )
541535
542536 const href = routerHistory . createHref ( fullPath )
543537 if ( __DEV__ ) {
You can’t perform that action at this time.
0 commit comments