All files / path-to-params index.js

100% Statements 11/11
50% Branches 2/4
100% Functions 2/2
100% Lines 10/10
1 2 3 4 5 6 7 8 9 10 11 12 131x 1x 5x 5x 5x 3x 3x 3x 2x   3x    
const pathToRegexp = require('path-to-regexp');
module.exports = (path = '*', url = '/') => {
  let keys = [];
  re = pathToRegexp(path, keys);
  if (!re.test(url)) return;
  const params = {};
  const exec = re.exec(url);
  keys.forEach((val, i) => {
    params[val.name] = exec[i + 1];
  });
  return params;
}