Skip to content
Snippets Groups Projects
Commit 71968709 authored by m431m's avatar m431m :speech_balloon:
Browse files

Merge branch 'redmine-issues/15312' into 'develop'

REDMINE_ISSUE-15312

See merge request onegeo-suite/sites/onegeo-suite-site-login-vuejs!30
parents 73307536 5ddd9467
No related branches found
No related tags found
No related merge requests found
Pipeline #11822 passed
......@@ -22,12 +22,29 @@ const routes = [
const locale = to.params.locale;
const supported_locales = process.env.VUE_APP_I18N_SUPPORTED_LOCALE.split(',');
if (!locale || (locale && !supported_locales.includes(locale) && locale.length !== 2)) {
if (!locale) {
return next({
path: `${process.env.VUE_APP_I18N_DEFAULT_LOCALE}${to.path.endsWith('/') ? to.path : normalizePathname(to.path)}`,
query: to.query
});
}
if (locale && locale.length !== 2) {
return next({
path: `${process.env.VUE_APP_I18N_DEFAULT_LOCALE}${to.path.endsWith('/') ? to.path : normalizePathname(to.path)}`,
query: to.query
});
}
if (locale && !supported_locales.includes(locale)) {
return next({
path:
`${process.env.VUE_APP_I18N_DEFAULT_LOCALE}${to.path.slice(3).endsWith('/') ?
to.path.slice(3) :
normalizePathname(to.path.slice(3))}`,
query: to.query
});
}
if (!to.path.endsWith('/')) {
return next({
......@@ -105,7 +122,7 @@ const routes = [
component: () => import('@/views/UserProfile.vue'),
},
{
path: '*',
path: 'not-found',
name: 'NotFound',
component: () => import('@/views/NotFound.vue'),
},
......@@ -113,7 +130,25 @@ const routes = [
},
{
path: '*',
redirect: `${process.env.VUE_APP_I18N_DEFAULT_LOCALE}`,
name: 'Fallback',
beforeEnter: (to, from, next) => {
const matchedRoutes = router.resolve(
`${process.env.VUE_APP_I18N_DEFAULT_LOCALE}${to.path.endsWith('/') ?
to.path :
normalizePathname(to.path)}`
).resolved.matched;
if (
matchedRoutes && !matchedRoutes.find(el => el.name === 'Fallback')
) {
return next({
path: `${process.env.VUE_APP_I18N_DEFAULT_LOCALE}${to.path.endsWith('/') ? to.path : normalizePathname(to.path)}`,
query: to.query
});
}
return next({
path: 'not-found/',
});
}
}
];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment