( Nuxt's Vue-router ) How to differentiate path ending with "/" and without

Viewed 82

Using the extendRoutes attribute for nuxt's router, I am attempting to differentiate paths ending with a slash and paths that do not. This is due to how the CMS we are using handles paths.

I could differentiate them by distinguishing the overview page as a path ending in /all or /overview, but it's not ideal.

I have a _slug.vue on my pages directory

(Should match /articles/some-article-1)

And I have a route for the articles overview with nested categories.

(Should match /articles/ /articles/category/ and /articles/category/category-of-category/)

This appears to work,

            routes.unshift({
                name: 'articles',
                path: '/articles/:category([^/]*/)',
                component: resolve(__dirname, 'pages/-overview.vue')
            })

but raises an error:

Expected "category" to match "[^/]*/", but received "dfdf%2F

How do I properly match paths terminating in slash?

1 Answers
Related