fix(nuxt): warn about ignored char while parsing route segment (#30396)

This commit is contained in:
Julien Huang 2025-01-14 13:43:21 +01:00 committed by GitHub
parent 746e4115bd
commit 2fee14df8b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -124,7 +124,7 @@ export function generateRoutesFromFiles (files: ScannedFile[], options: Generate
for (let i = 0; i < segments.length; i++) { for (let i = 0; i < segments.length; i++) {
const segment = segments[i] const segment = segments[i]
const tokens = parseSegment(segment!) const tokens = parseSegment(segment!, file.absolutePath)
// Skip group segments // Skip group segments
if (tokens.every(token => token.type === SegmentTokenType.group)) { if (tokens.every(token => token.type === SegmentTokenType.group)) {
@ -337,7 +337,7 @@ function getRoutePath (tokens: SegmentToken[]): string {
const PARAM_CHAR_RE = /[\w.]/ const PARAM_CHAR_RE = /[\w.]/
function parseSegment (segment: string) { function parseSegment (segment: string, absolutePath: string) {
let state: SegmentParserState = SegmentParserState.initial let state: SegmentParserState = SegmentParserState.initial
let i = 0 let i = 0
@ -425,7 +425,7 @@ function parseSegment (segment: string) {
} else if (c && PARAM_CHAR_RE.test(c)) { } else if (c && PARAM_CHAR_RE.test(c)) {
buffer += c buffer += c
} else { } else {
// console.debug(`[pages]Ignored character "${c}" while building param "${buffer}" from "segment"`) logger.warn(`'\`${c}\`' is not allowed in a dynamic route parameter and has been ignored. Consider renaming \`${absolutePath}\`.`)
} }
break break
} }