mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-06-16 21:21:27 +08:00
fix: don't use flat since it's not supported in node
This commit is contained in:
@@ -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('/');
|
||||
}
|
||||
|
||||
@@ -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('/');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user