used regex instead of slice

Signed-off-by: Alex Rybchenko <arybchenko@box.com>
This commit is contained in:
Alex Rybchenko
2021-11-02 09:28:15 +01:00
parent 8666b7bc90
commit 5846833175
@@ -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;