Skip to content

Commit

Permalink
fix warn
Browse files Browse the repository at this point in the history
cleanup
  • Loading branch information
s00d committed Apr 28, 2024
1 parent fe629fc commit 202bd25
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
22 changes: 2 additions & 20 deletions src/runtime/plugins/i18n.ts
Expand Up @@ -172,6 +172,7 @@ export default defineNuxtPlugin({
notInitialSetup = false
}

// don't use routeToObject. it's make memory leak
const subRoute = {
name: route.name,
params: route.params,
Expand All @@ -186,16 +187,6 @@ export default defineNuxtPlugin({

const oldLocale = getLocaleFromRoute(subRoute)

if (
subRoute.name &&
(runtimeI18n.defaultLocale !== locale || runtimeI18n.strategy === 'prefix')
// || (getLocaleFromRoute(route) && runtimeI18n.strategy === 'prefix_and_default')
) {
const newName = subRoute.name.toString().replace(runtimeI18n.routesNameSeparator + 'locale', '')
subRoute.name = newName + runtimeI18n.routesNameSeparator + 'locale'
subRoute.params = { ...subRoute.params, ...{ locale: locale } }
}

const redirectPath = await nuxtContext.runWithContext(() =>
detectRedirect({
route: { to: subRoute },
Expand Down Expand Up @@ -481,6 +472,7 @@ export default defineNuxtPlugin({
notInitialSetup = false
}

// don't use routeToObject. is's make memory leak
const subRoute = {
name: to.name,
params: to.params,
Expand All @@ -495,16 +487,6 @@ export default defineNuxtPlugin({

const oldLocale = getLocaleFromRoute(subRoute)

if (
subRoute.name &&
(runtimeI18n.defaultLocale !== locale || runtimeI18n.strategy === 'prefix')
// || (getLocaleFromRoute(route) && runtimeI18n.strategy === 'prefix_and_default')
) {
const newName = subRoute.name.toString().replace(runtimeI18n.routesNameSeparator + 'locale', '')
subRoute.name = newName + runtimeI18n.routesNameSeparator + 'locale'
subRoute.params = { ...subRoute.params, ...{ locale: locale } }
}

const redirectPath = await nuxtContext.runWithContext(() =>
detectRedirect({
route: { to: subRoute, from },
Expand Down
4 changes: 4 additions & 0 deletions src/runtime/routing/compatibles/routing.ts
Expand Up @@ -365,6 +365,10 @@ export function switchLocalePath(

const baseRoute = { ...routeCopy, name, params: { ...routeCopy.params, ...resolvedParams } }

if (baseRoute.params) {
delete baseRoute.params.locale
}

const path = localePath(common, baseRoute, locale)

// custom locale path with interceptor
Expand Down

0 comments on commit 202bd25

Please sign in to comment.