UNPKG

@patternplate/client

Version:

Universal javascript client application for patternplate

30 lines (24 loc) 757 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getDepth = getDepth; exports.default = void 0; var _reduxActions = require("redux-actions"); function getDepth(pathname) { const fragments = pathname.split("/").filter(Boolean); const fragmentIndex = ["pattern", "doc"].map(known => fragments.indexOf(known)).find(index => index !== -1); const index = fragmentIndex === null ? fragments.length : fragmentIndex; return fragments.slice(0, index).filter(Boolean).length; } var _default = (0, _reduxActions.handleAction)("@@router/LOCATION_CHANGE", { next(_, { payload: { pathname } }) { return getDepth(pathname); } }, "."); exports.default = _default; //# sourceMappingURL=depth.js.map