UNPKG

881 BJavaScriptView Raw
1export default function checkDuplicateRouteNames(state) {
2 const duplicates = [];
3
4 const getRouteNames = (location, state) => {
5 state.routes.forEach(route => {
6 var _route$state, _route$state$routeNam;
7
8 const currentLocation = location ? `${location} > ${route.name}` : route.name;
9 (_route$state = route.state) === null || _route$state === void 0 ? void 0 : (_route$state$routeNam = _route$state.routeNames) === null || _route$state$routeNam === void 0 ? void 0 : _route$state$routeNam.forEach(routeName => {
10 if (routeName === route.name) {
11 duplicates.push([currentLocation, `${currentLocation} > ${route.name}`]);
12 }
13 });
14
15 if (route.state) {
16 getRouteNames(currentLocation, route.state);
17 }
18 });
19 };
20
21 getRouteNames('', state);
22 return duplicates;
23}
24//# sourceMappingURL=checkDuplicateRouteNames.js.map
\No newline at end of file