mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-06 21:10:38 +00:00
fix: i18n lint issue
This commit is contained in:
parent
6494873f70
commit
03f89421c2
@ -1,5 +1,5 @@
|
||||
export default function ({ isHMR, app, store, route, params, error, redirect }) {
|
||||
const defaultLocale = app.i18n.fallbackLocale;
|
||||
const defaultLocale = app.i18n.fallbackLocale
|
||||
// If middleware is called from hot module replacement, ignore it
|
||||
if (isHMR) return
|
||||
// Get locale from params
|
||||
@ -11,10 +11,9 @@ export default function ({ isHMR, app, store, route, params, error, redirect })
|
||||
store.commit('SET_LANG', locale)
|
||||
app.i18n.locale = store.state.locale
|
||||
// If route is /<defaultLocale>/... -> redirect to /...
|
||||
if (locale === defaultLocale && route.fullPath.indexOf('/'+defaultLocale) === 0) {
|
||||
|
||||
var toReplace = '^/'+defaultLocale
|
||||
var re = new RegExp(toReplace);
|
||||
if (locale === defaultLocale && route.fullPath.indexOf('/' + defaultLocale) === 0) {
|
||||
const toReplace = '^/' + defaultLocale
|
||||
const re = new RegExp(toReplace)
|
||||
return redirect(
|
||||
route.fullPath.replace(re, '/')
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user