Reputation: 27058
I have this route /test/a-vs-b
I am trying to catch this route only if -vs-
is found in it.
I tried a few regex variants, but nothing seems to work
routes.push({
name: 'test',
path: '/test/:page((.*)-vs-(.*))',
component: resolve(__dirname, 'test/b.vue'),
});
Any ideas?
Upvotes: 2
Views: 3971
Reputation: 55664
VueRouter uses the path-to-regexp
library, which apparently doesn't handle defining capturing groups with parenthesis like you're trying to do.
I got it to work by simply removing the parenthesis surrounding the .*
s.
routes.push({
name: 'test',
path: '/test/:page(.*-vs-.*)',
component: resolve(__dirname, 'test/b.vue'),
});
Upvotes: 4