Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 5x 3x 3x 1x 4x | import { isEnabled } from './service' import { parseParameter } from './utils' /** * @example * const router = new VueRouter({ * routes: [ * { path: '/test1', component: Test1Component, meta: { featureFlipping: 'XXXXX' } }, * { path: '/test2', component: Test2Component, meta: { featureFlipping: { key: 'XXXXX' } } }, * { path: '/test3', component: Test3Component, meta: { featureFlipping: { key: 'XXXXX', default: true } } }, * ] * }) */ export async function featureFlippingGuard (to, from, next) { if (to.meta.featureFlipping) { let [key, defaut] = parseParameter(to.meta.featureFlipping) if (!isEnabled(key, defaut)) { return next({path: '/'}) } } return next() } |