Function: detectDuplicateRoutes()
API / @xmachines/play-router / detectDuplicateRoutes
function detectDuplicateRoutes(routes): void;Defined in: validate-routes.ts:70
Finds each duplicate route path
The function THROWS AN ERROR when more than one state holds the same RESOLVED complete path.
The detection works on the resolved complete paths, after buildRouteTree put the
path of each parent before its relative routes. It does not work on the raw route
strings: two relative "settings" routes below two different parents resolve to
two different complete paths, and they are valid; a relative route and an absolute
route that resolve to the same URL are a real collision, and the function refuses
them. buildRouteTree calls this function when the complete paths are known.
The reason: a routing on the URL requires one state for each URL. Two states at the same path make the browser navigation ambiguous, for the BACK button and for a direct URL. Use a different path for each state, or use one state with a conditional render.
Parameters
| Parameter | Type | Description |
|---|---|---|
routes | ResolvedRoutePath[] | The array of the route entries with their resolved complete paths, for example the RouteNode objects |
Returns
void
Throws
When the function finds two resolved route paths that are equal