<commit_before>import React  from 'react';
import assign from 'object-assign';

function ReactAutolinkMixin() {
  let delimiter = /((?:https?:\/\/)?(?:(?:[a-z0-9][a-z0-9\-]{1,61}[a-z0-9]\.)+[a-z\.]*[a-z]+|(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3})(?::\d{1,5})*[a-z0-9.,_\/~#&=;%+?-]*)/ig;

  return {
    autolink(text, options = {}, bufs = []) {
      if (!text) return null;

      return text.split(delimiter).map(word => {
        let match = word.match(delimiter);
        if (match) {
          let url = match[0];
            return React.createElement(
              'a',
              assign({href: url.startsWith('http') ? url : `http://${url}`}, options),
              url
            );
        } else {
          return word;
        }
      });
    }
  };
}

export default ReactAutolinkMixin();
<commit_msg>Use const and self implement String.prototype.startsWith for compat<commit_after>import React  from 'react';
import assign from 'object-assign';

function ReactAutolinkMixin() {
  const delimiter = /((?:https?:\/\/)?(?:(?:[a-z0-9][a-z0-9\-]{1,61}[a-z0-9]\.)+[a-z\.]*[a-z]+|(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3})(?::\d{1,5})*[a-z0-9.,_\/~#&=;%+?-]*)/ig;

  let strStartsWith = (str, prefix) => {
    return str.slice(0, prefix.length) === prefix;
  };

  return {
    autolink(text, options = {}, bufs = []) {
      if (!text) return null;

      return text.split(delimiter).map(word => {
        let match = word.match(delimiter);
        if (match) {
          let url = match[0];
            return React.createElement(
              'a',
              assign({href: strStartsWith(url, 'http') ? url : `http://${url}`}, options),
              url
            );
        } else {
          return word;
        }
      });
    }
  };
}

export default ReactAutolinkMixin();

{'fraction_non_alphanumeric': 0.25684210526315787, 'fraction_numerical': 0.04789473684210526, 'mean_word_length': 2.3003472222222223, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '5683777', 'n_tokens_mistral': 769, 'n_tokens_neox': 755, 'n_words': 108}