Welcome to mirror list, hosted at ThFree Co, Russian Federation.

router.js « alert_details « vue_shared « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 26477a3a66a35f9584b6b2329ccb11b359971a9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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) {
  const router = new VueRouter({
    mode: 'history',
    base: joinPaths(gon.relative_url_root || '', base),
    routes: [{ path: '/:tabId', name: 'tab' }],
  });

  /* 
    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;
}