fix(nuxt): escape colons in page paths (#21731)

This commit is contained in:
Daniel Roe 2023-06-25 17:40:30 +01:00 committed by GitHub
parent c72bc95473
commit 1cd48cbef9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -104,7 +104,7 @@ function getRoutePath (tokens: SegmentToken[]): string {
? `:${token.value}()`
: token.type === SegmentTokenType.catchall
? `:${token.value}(.*)*`
: encodePath(token.value))
: encodePath(token.value).replace(/:/g, '\\:'))
)
}, '/')
}

View File

@ -279,6 +279,20 @@ describe('pages:generateRoutesFromFiles', () => {
children: []
}
]
},
{
description: 'should allow pages with `:` in their path',
files: [
`${pagesDir}/test:name.vue`
],
output: [
{
name: 'test:name',
path: '/test\\:name',
file: `${pagesDir}/test:name.vue`,
children: []
}
]
}
]