used regex instead of slice
Signed-off-by: Alex Rybchenko <arybchenko@box.com>
This commit is contained in:
@@ -35,8 +35,8 @@ export function useSelectedSubRoute(subRoutes: SubRoute[]): {
|
||||
|
||||
// TODO: remove once react-router updated
|
||||
const sortedRoutes = routes.sort((a, b) =>
|
||||
// remove added "/*" symbols from path before comparing
|
||||
b.path.slice(0, -2).localeCompare(a.path.slice(0, -2)),
|
||||
// remove "/*" symbols from path end before comparing
|
||||
b.path.replace(/\/\*$/, '').localeCompare(a.path.replace(/\/\*$/, '')),
|
||||
);
|
||||
|
||||
const element = useRoutes(sortedRoutes) ?? subRoutes[0].children;
|
||||
|
||||
Reference in New Issue
Block a user