<commit_before>import RLookup from 'rlookup';

function parseParams(params, text='') {
  Object.keys(params).forEach(param => text = text.replace(new RegExp(`(.*):(${param})(.*)`), `$1${params[param]}$3`));
  return text;
}

function parseProps(params, props) {
  let newProps = {};
  Object.keys(props).forEach(key => newProps[key] = parseParams(params, props[key]));
  return newProps;
}

export default function match(route, moduleName) {
  const module = require(moduleName);

  const panelMatch = new RLookup({
    patterns: module.lookup
  }).match(route.path);

  if (typeof panelMatch !== 'undefined') {
    const panel = module.panels[panelMatch.pattern];

    return {
      background: panel.background,
      props: parseProps(panelMatch.params, panel.props),
      title: panel.title,
      type: panel.type,
      width: panel.width
    };
  }
}
<commit_msg>fix: include all properties in dynamic panels<commit_after>import RLookup from 'rlookup';

function parseParams(params, text='') {
  Object.keys(params).forEach(param => text = text.replace(new RegExp(`(.*):(${param})(.*)`), `$1${params[param]}$3`));
  return text;
}

function parseProps(params, props) {
  let newProps = {};
  Object.keys(props).forEach(key => newProps[key] = parseParams(params, props[key]));
  return newProps;
}

export default function match(route, moduleName) {
  const module = require(moduleName);

  const panelMatch = new RLookup({
    patterns: module.lookup
  }).match(route.path);

  if (typeof panelMatch !== 'undefined') {
    const panel = module.panels[panelMatch.pattern];

    return {
      ...panel,
      props: parseProps(panelMatch.params, panel.props)
    };
  }
}

{'fraction_non_alphanumeric': 0.1625, 'fraction_numerical': 0.002380952380952381, 'mean_word_length': 4.269592476489028, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4691909', 'n_tokens_mistral': 530, 'n_tokens_neox': 519, 'n_words': 117}