mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-18 17:35:57 +00:00
fix(nuxt): warn about ignored char while parsing route segment (#30396)
This commit is contained in:
parent
746e4115bd
commit
2fee14df8b
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user