Function: buildRouteTree()
API / @xmachines/play-router / buildRouteTree
function buildRouteTree(routes): RouteTree;Defined in: build-tree.ts:22
Builds the hierarchical route tree from the flat list of the routes
The function makes a nested tree, and it keeps the parent-child relation of the states. An absolute route becomes a route of the top level, and a relative route goes below its parent. The function also makes the maps of both directions, for the lookup between a state ID and a path.
The detection of a duplicate runs here, after the function resolved each relative
route against the complete path of its parent. Therefore two relative routes with
the same raw string below two different parents are valid, and two different raw
strings that resolve to the same complete path are not: those two overwrite each
other in byPath in silence.
Parameters
| Parameter | Type | Description |
|---|---|---|
routes | RouteInfo[] | The flat list of the RouteInfo objects, from the extraction |
Returns
The RouteTree, with its root, its byStateId map, and its byPath map
Throws
When two states resolve to the same complete path