react-router
Version:
A complete routing library for React
26 lines (19 loc) • 569 B
JavaScript
exports.__esModule = true;
var _PatternUtils = require('./PatternUtils');
/**
* Extracts an object of params the given route cares about from
* the given params object.
*/
function getRouteParams(route, params) {
var routeParams = {};
if (!route.path) return routeParams;
(0, _PatternUtils.getParamNames)(route.path).forEach(function (p) {
if (Object.prototype.hasOwnProperty.call(params, p)) {
routeParams[p] = params[p];
}
});
return routeParams;
}
exports.default = getRouteParams;
module.exports = exports['default'];
;