mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-20 07:30:57 +00:00
fix: dynamic routes must start with an underscore
Folders or files within `pages/` should only lead to dynamic routes, if they start with an underscore. Previously, folders like `some_folder` would lead to a route parameter `folder` being introduced.
This commit is contained in:
parent
f57096e572
commit
751aae38d4
@ -297,8 +297,13 @@ export const createRoutes = function createRoutes(files, srcDir, pagesDir) {
|
|||||||
if (key === 'index' && i + 1 === keys.length) {
|
if (key === 'index' && i + 1 === keys.length) {
|
||||||
route.path += i > 0 ? '' : '/'
|
route.path += i > 0 ? '' : '/'
|
||||||
} else {
|
} else {
|
||||||
route.path += '/' + (key === '_' ? '*' : key.replace('_', ':'))
|
route.path += '/' +
|
||||||
if (key !== '_' && key.indexOf('_') !== -1) {
|
(key === '_'
|
||||||
|
? '*'
|
||||||
|
: key.indexOf('_') === 0
|
||||||
|
? key.replace('_', ':')
|
||||||
|
: key)
|
||||||
|
if (key !== '_' && key.indexOf('_') === 0) {
|
||||||
route.path += '?'
|
route.path += '?'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user