1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4 |
|
5 | Object.defineProperty(exports, "__esModule", {
|
6 | value: true
|
7 | });
|
8 | exports["default"] = exports.collectUniversalRoutes = void 0;
|
9 |
|
10 | var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
11 |
|
12 | var _lodash = require("lodash");
|
13 |
|
14 | var _flatten = _interopRequireDefault(require("lodash/flatten"));
|
15 |
|
16 | var collectUniversalRoutes = function collectUniversalRoutes(route) {
|
17 | var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
18 | _ref$path = _ref.path,
|
19 | parentPath = _ref$path === void 0 ? '' : _ref$path;
|
20 |
|
21 | if (Array.isArray(route)) return (0, _flatten["default"])(route.map(collectUniversalRoutes));
|
22 |
|
23 | if ((0, _lodash.isPlainObject)(route)) {
|
24 | var path = [parentPath, route.path].join('#');
|
25 | var children = route.children ? (0, _flatten["default"])(route.children.map(function (a) {
|
26 | return collectUniversalRoutes(a, {
|
27 | path: path
|
28 | });
|
29 | })) : [];
|
30 | return [path].concat((0, _toConsumableArray2["default"])(children));
|
31 | }
|
32 |
|
33 | return [];
|
34 | };
|
35 |
|
36 | exports.collectUniversalRoutes = collectUniversalRoutes;
|
37 | var _default = collectUniversalRoutes;
|
38 | exports["default"] = _default;
|
39 |
|
\ | No newline at end of file |