Background
In packages/structure/src/model/RWRoute.ts, the hasPathCollision getter is responsible for generating the 'Duplicate Path' diagnostic. It uses a local helper function removeParamNames to normalize paths before comparing them:
function removeParamNames(p: string) {
// TODO: implement
// foo/{bar}/baz --> foo/{}/baz
return p
}
The function is not implemented — it just returns p unchanged. This means that routes like:
/users/{id} and /users/{userId}
/posts/{id:Int} and /posts/{slug:String}
are not detected as path collisions, even though they would match the same URL patterns at runtime, causing ambiguous routing behavior.
What needs to be done
Implement removeParamNames to strip parameter names (and types) from path segments, so that two paths with the same structure but different parameter names are recognized as duplicates.
Fix:
function removeParamNames(p: string) {
// foo/{bar}/baz --> foo/{}/baz
// foo/{id:Int}/baz --> foo/{}/baz
return p.replace(/\{[^}]+\}/g, '{}')
}
This regex replaces any {...} segment (including typed params like {id:Int}) with {}, normalizing the path for comparison.
File
packages/structure/src/model/RWRoute.ts, line 268–271
Impact
Without this fix, users can accidentally define two routes that match the same URL (e.g., <Route path="/post/{id}" ...> and <Route path="/post/{slug}" ...>) and the IDE/CLI diagnostic tool will not warn them. The router will silently use whichever route appears first.
Background
In
packages/structure/src/model/RWRoute.ts, thehasPathCollisiongetter is responsible for generating the'Duplicate Path'diagnostic. It uses a local helper functionremoveParamNamesto normalize paths before comparing them:The function is not implemented — it just returns
punchanged. This means that routes like:/users/{id}and/users/{userId}/posts/{id:Int}and/posts/{slug:String}are not detected as path collisions, even though they would match the same URL patterns at runtime, causing ambiguous routing behavior.
What needs to be done
Implement
removeParamNamesto strip parameter names (and types) from path segments, so that two paths with the same structure but different parameter names are recognized as duplicates.Fix:
This regex replaces any
{...}segment (including typed params like{id:Int}) with{}, normalizing the path for comparison.File
packages/structure/src/model/RWRoute.ts, line 268–271Impact
Without this fix, users can accidentally define two routes that match the same URL (e.g.,
<Route path="/post/{id}" ...>and<Route path="/post/{slug}" ...>) and the IDE/CLI diagnostic tool will not warn them. The router will silently use whichever route appears first.