fix: don't use flat since it's not supported in node

This commit is contained in:
Satyajit Sahoo
2020-05-14 13:22:14 +02:00
parent 2ff0531695
commit 21b397f0d6
2 changed files with 10 additions and 9 deletions

View File

@@ -189,9 +189,8 @@ type ConfigItem = {
};
function joinPaths(...paths: string[]): string {
return paths
.map((p) => p.split('/'))
.flat()
return ([] as string[])
.concat(...paths.map((p) => p.split('/')))
.filter(Boolean)
.join('/');
}

View File

@@ -64,9 +64,12 @@ export default function getStateFromPath(
let initialRoutes: InitialRouteConfig[] = [];
// Create a normalized configs array which will be easier to use
const configs = Object.keys(options)
.map((key) => createNormalizedConfigs(key, options, [], initialRoutes))
.flat()
const configs = ([] as RouteConfig[])
.concat(
...Object.keys(options).map((key) =>
createNormalizedConfigs(key, options, [], initialRoutes)
)
)
.sort(
(a, b) =>
// Sort configs so the most exhaustive is always first to be chosen
@@ -232,9 +235,8 @@ export default function getStateFromPath(
}
function joinPaths(...paths: string[]): string {
return paths
.map((p) => p.split('/'))
.flat()
return ([] as string[])
.concat(...paths.map((p) => p.split('/')))
.filter(Boolean)
.join('/');
}