debian-mirror-gitlab/app/assets/javascripts/vue_shared/alert_details/router.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
742 B
JavaScript
Raw Normal View History

2020-10-24 23:57:45 +05:30
import Vue from 'vue';
import VueRouter from 'vue-router';
import { joinPaths } from '~/lib/utils/url_utility';
Vue.use(VueRouter);
export default function createRouter(base) {
2023-01-13 00:05:48 +05:30
const router = new VueRouter({
mode: 'history',
2020-10-24 23:57:45 +05:30
base: joinPaths(gon.relative_url_root || '', base),
routes: [{ path: '/:tabId', name: 'tab' }],
});
2023-01-13 00:05:48 +05:30
/*
Backward-compatible behavior. Redirects hash mode URLs to history mode ones.
Ex: from #/overview to /overview
from #/metrics to /metrics
from #/activity to /activity
*/
router.beforeEach((to, _, next) => {
if (to.hash.startsWith('#/')) {
const path = to.fullPath.substring(2);
next(path);
} else {
next();
}
});
return router;
2020-10-24 23:57:45 +05:30
}