@@ -5,7 +5,7 @@ import { isVue3, isRef, unref, isVue2 } from 'vue-demi'
5
5
import { DEFAULT_DYNAMIC_PARAMS_KEY } from '../constants'
6
6
import { getLocale , getLocaleRouteName , getRouteName } from '../utils'
7
7
8
- import { getI18nRoutingOptions , resolve } from './utils'
8
+ import { getI18nRoutingOptions , resolve , routeToObject } from './utils'
9
9
10
10
import type { RoutingProxy , PrefixableOptions , SwitchLocalePathIntercepter } from './types'
11
11
import type { Strategies , I18nRoutingOptions } from '../types'
@@ -298,23 +298,24 @@ export function switchLocalePath(this: RoutingProxy, locale: Locale): string {
298
298
const { switchLocalePathIntercepter, dynamicRouteParamsKey } = getI18nRoutingOptions ( this . router , this )
299
299
300
300
// prettier-ignore
301
- const { params , ... routeCopy } = isVue3
301
+ const routeValue = isVue3
302
302
? ( route as RouteLocationNormalizedLoaded ) // for vue-router v4
303
303
: isRef < Route > ( route ) // for vue-router v3
304
304
? route . value
305
305
: route
306
+ const routeCopy = routeToObject ( routeValue )
306
307
const langSwitchParams = getLocalizableMetaFromDynamicParams ( route , dynamicRouteParamsKey ) [ locale ] || { }
307
308
308
309
// eslint-disable-next-line @typescript-eslint/no-explicit-any
309
310
const _baseRoute : any = {
310
311
name,
311
312
params : {
312
- ...params ,
313
+ ...routeCopy . params ,
313
314
...langSwitchParams
314
315
}
315
316
}
316
317
if ( isVue2 ) {
317
- _baseRoute . params [ 0 ] = params . pathMatch
318
+ _baseRoute . params [ 0 ] = routeCopy . params . pathMatch
318
319
}
319
320
320
321
const baseRoute = assign ( { } , routeCopy , _baseRoute )
0 commit comments