<commit_before>var React = require('react');
var createSideEffect = require('react-side-effect');
var Children = React.Children;
var PropTypes = React.PropTypes;

var utils = require('./utils');
var clone = utils.clone;
var defaults = utils.defaults;
var forEach = utils.forEach;

function getProps(propsList) {

  var props = {};

  var extend = true;

  for (var i = propsList.length - 1; extend && i >= 0; i--) {

    var _props = clone(propsList[i]);

    if (_props.description) {
      defaults(_props, {meta : {name : {description : _props.description}}});
    }
    if (_props.canonical) {
      defaults(_props, {link : {rel : {canonical : _props.canonical}}});
    }


    defaults(props, _props);
    extend = _props.hasOwnProperty('extend');

  }

  if (props.auto) {
    autoProps(props);
  }

  return props;

}

function autoProps(props) {
  if (props.auto.ograph === true) {
    ograph(props);
  }

  return props;
}

function ograph(p) {

  if (!p.meta) {
    p.meta = {};
  }
  if (!p.meta.property) {
    p.meta.property = {};
  }

  var group = p.meta.property;
  if (group) {

    if (p.title && !group['og:title']) {
      group['og:title'] = p.title;
    }
    if (p.description && !group['og:description']) {
      group['og:description'] = p.description;
    }
    if (p.canonical && !group['og:url']) {
      group['og:url'] = p.canonical;
    }

  }
  return p;

}

function parseTags(tagName, props) {

  props = props || {};
  var tags = [];
  var contentKey = tagName === 'link' ? 'href' : 'content';
  Object.keys(props).forEach(function (groupKey) {

    var group = props[groupKey];
    if (typeof group === 'string') {
      var tag = {
        tagName : tagName
      };
      tag.groupKey = group;

      tags.push(tag);

      return;
    }
    Object.keys(group).forEach(function (key) {
      var values = Array.isArray(group[key]) ? group[key] : [group[key]];
      values.forEach(function (value) {

        var tag = {
          tagName : tagName
        };
        tag.groupKey = key;
        tag.contentKey = value;

        tags.push(tag);
      });
    });

  });
  return tags;

}

function getTags(_props) {
  return [].concat(parseTags('meta', _props.meta), parseTags('link', _props.link));
}


function removeNode(node) {
  node.parentNode.removeChild(node);
}

function removeDocumentMeta() {
  forEach(document.querySelectorAll('head [data-rdm]'), removeNode);
}

function insertDocumentMetaNode(entry) {
<commit_msg>dynamic key fix<commit_after>var React = require('react');
var createSideEffect = require('react-side-effect');
var Children = React.Children;
var PropTypes = React.PropTypes;

var utils = require('./utils');
var clone = utils.clone;
var defaults = utils.defaults;
var forEach = utils.forEach;

function getProps(propsList) {

  var props = {};

  var extend = true;

  for (var i = propsList.length - 1; extend && i >= 0; i--) {

    var _props = clone(propsList[i]);

    if (_props.description) {
      defaults(_props, {meta : {name : {description : _props.description}}});
    }
    if (_props.canonical) {
      defaults(_props, {link : {rel : {canonical : _props.canonical}}});
    }


    defaults(props, _props);
    extend = _props.hasOwnProperty('extend');

  }

  if (props.auto) {
    autoProps(props);
  }

  return props;

}

function autoProps(props) {
  if (props.auto.ograph === true) {
    ograph(props);
  }

  return props;
}

function ograph(p) {

  if (!p.meta) {
    p.meta = {};
  }
  if (!p.meta.property) {
    p.meta.property = {};
  }

  var group = p.meta.property;
  if (group) {

    if (p.title && !group['og:title']) {
      group['og:title'] = p.title;
    }
    if (p.description && !group['og:description']) {
      group['og:description'] = p.description;
    }
    if (p.canonical && !group['og:url']) {
      group['og:url'] = p.canonical;
    }

  }
  return p;

}

function parseTags(tagName, props) {

  props = props || {};
  var tags = [];
  var contentKey = tagName === 'link' ? 'href' : 'content';
  Object.keys(props).forEach(function (groupKey) {

    var group = props[groupKey];
    if (typeof group === 'string') {
      var tag = {
        tagName : tagName
      };
      tag[groupKey] = group;

      tags.push(tag);

      return;
    }
    Object.keys(group).forEach(function (key) {
      var values = Array.isArray(group[key]) ? group[key] : [group[key]];
      values.forEach(function (value) {

        var tag = {
          tagName : tagName
        };
        tag[groupKey] = key;
        tag[contentKey] = value;

        tags.push(tag);
      });
    });

  });
  return tags;

}

function getTags(_props) {
  return [].concat(parseTags('meta', _props.meta), parseTags('link', _props.link));
}


function removeNode(node) {
  node.parentNode.removeChild(node);
}

function removeDocumentMeta() {
  forEach(document.querySelectorAll('head [data-rdm]'), removeNode);
}

function insertDocumentMetaNode(entry) {

{'fraction_non_alphanumeric': 0.1673073032571313, 'fraction_numerical': 0.0008092251669026907, 'mean_word_length': 2.850467289719626, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2426681', 'n_tokens_mistral': 1678, 'n_tokens_neox': 1631, 'n_words': 344}