fix: i18n lint issue

This commit is contained in:
Clark Du 2018-03-01 21:03:36 +08:00
parent 6494873f70
commit 03f89421c2
No known key found for this signature in database
GPG Key ID: D0E5986AF78B86D9
1 changed files with 4 additions and 5 deletions

View File

@ -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, '/')
)