Recently, I integrated a route with a parameter in my Vue project.
const routes = [
{
path: "/:lang(^$|^es$|^pt$|^cn$)",
name: "Home",
component: Page,
},
{
path: "/privacy",
name: "Privacy",
component: Privacy,
},
{
path: "*",
name: "NotFound",
component: NotFound,
}
];
I want the route to activate under specific conditions:
- If lang is empty
- If lang is es, pt, or cn, but not a combination of those
All other cases should redirect to the NotFound route
The regex I'm using has been tested on the JavaScript engine at https://regexplanet.com
Despite trying different variations, I haven't been successful in making it work properly within Vue yet.