Repository URL to install this package:
|
Version:
6.0.0 ▾
|
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const exotic_1 = require("exotic");
const matchPath_1 = __importDefault(require("react-router-dom/matchPath"));
const routes_1 = require("./routes");
// @TODO @FIXME some issue with import order
// import routes from 'bootstrapper/routes'
/**
* @description what this does is match our params in bootstrapper/routes
* @param {*} pathname
*/
function matchRouteParams(pathname) {
let matched = {};
// go through our routes
// use the sealed object for perf
// match params (which has a cache)
// merge with matched object
// return matched
for (let index = 0; index < routes_1.routePathsList.length; index++) {
const matchablePath = routes_1.routePathsList[index];
routes_1.routePathCurrent.path = matchablePath;
const matchedFromPath = matchPath_1.default(pathname, routes_1.routePathCurrent);
if (exotic_1.isObj(matchedFromPath)) {
// this.log(pathname, { routePathCurrent, matchedFromPath, pathname })
Object.assign(matched, matchedFromPath.params);
// access to which route had the data
// Object.defineProperty(matched, '@@matches', {
// writable: false,
// configurable: false,
// enumerable: false,
// value: matchedFromPath,
// })
}
}
// if (this.props && isObj(this.props.match)) {
// matched = {
// ...matched,
// ...this.props.match,
// ...this.props.match.params,
// }
// } else {
// matched.match = matched
// }
}
exports.matchRouteParams = matchRouteParams;
//# sourceMappingURL=matchRouteParams.js.map