<commit_before>'use strict';

const R = require('ramda');

/**
 * Turn a string into a nice title.
 * @param {String}
 * @returns {String}
 * @example toTitle('some-slug_string'); => Some Slug String
 */
const toTitle = R.pipe(
  // String => Array
  R.split(/[\W_]+/),
  // Array => Array
  R.map(word => word.replace(/^\w/, R.toUpper)),
  // Array => String
  R.join(' ')
);

/**
 * Turn a string into a slug.
 * Inspired by https://gist.github.com/juanmhidalgo/3146760
 * @param {String}
 * @returns {String}
 * @example toSlug('Nice Title!'); => nice-title
 */
const toSlug = R.pipe(
  R.toLower,
  // Replace accent chars (TODO: needed?)
  R.replace(/[\u00C0-\u00C5]/ig, 'a'),
  R.replace(/[\u00C8-\u00CB]/ig, 'e'),
  R.replace(/[\u00CC-\u00CF]/ig, 'i'),
  R.replace(/[\u00D2-\u00D6]/ig, 'o'),
  R.replace(/[\u00D9-\u00DC]/ig, 'u'),
  R.replace(/[\u00D1]/ig, 'n'),
  R.replace(/[^a-z0-9 ]+/gi, ''),
  R.trim,
  R.replace(/\s/g, '-'),
  R.replace(/[\-]{2}/g, ''),
  R.replace(/[^a-z\- ]*/gi, '')
);

/**
 * Creates a GitHub repository URL.
 * @param {String} org
 * @param {String} name
 * @returns {String}
 * @example toGitHubUrl('foo', 'bar'); => <EMAIL>:foo/bar.git
 */
const toGitHubUrl = (org, name) => {
  const path = [org, name].map(toSlug).join('/');
  return `<EMAIL>:${path}.git`;
};

/**
 * Is a string a valid "slug"?
 * @param {String}
 * @returns {Boolean}
 * @example isSlug('no way Jose'); => false
 */
const isSlug = R.test(/^[a-z]{1}[a-z0-9\-]*[^\-]$/);
<commit_msg>Simplify `toGitHubUrl` utility<commit_after>'use strict';

const R = require('ramda');

/**
 * Turn a string into a nice title.
 * @param {String}
 * @returns {String}
 * @example toTitle('some-slug_string'); => Some Slug String
 */
const toTitle = R.pipe(
  // String => Array
  R.split(/[\W_]+/),
  // Array => Array
  R.map(word => word.replace(/^\w/, R.toUpper)),
  // Array => String
  R.join(' ')
);

/**
 * Turn a string into a slug.
 * Inspired by https://gist.github.com/juanmhidalgo/3146760
 * @param {String}
 * @returns {String}
 * @example toSlug('Nice Title!'); => nice-title
 */
const toSlug = R.pipe(
  R.toLower,
  // Replace accent chars (TODO: needed?)
  R.replace(/[\u00C0-\u00C5]/ig, 'a'),
  R.replace(/[\u00C8-\u00CB]/ig, 'e'),
  R.replace(/[\u00CC-\u00CF]/ig, 'i'),
  R.replace(/[\u00D2-\u00D6]/ig, 'o'),
  R.replace(/[\u00D9-\u00DC]/ig, 'u'),
  R.replace(/[\u00D1]/ig, 'n'),
  R.replace(/[^a-z0-9 ]+/gi, ''),
  R.trim,
  R.replace(/\s/g, '-'),
  R.replace(/[\-]{2}/g, ''),
  R.replace(/[^a-z\- ]*/gi, '')
);

/**
 * Creates a GitHub repository URL.
 * @param {String} org
 * @param {String} name
 * @returns {String}
 * @example toGitHubUrl('foo', 'bar'); => git@github.com:foo/bar.git
 */
const toGitHubUrl = (org, name) => {
  return `git@github.com:${org}/${name}.git`;
};

/**
 * Is a string a valid "slug"?
 * @param {String}
 * @returns {Boolean}
 * @example isSlug('no way Jose'); => false
 */
const isSlug = R.test(/^[a-z]{1}[a-z0-9\-]*[^\-]$/);

{'fraction_non_alphanumeric': 0.261455525606469, 'fraction_numerical': 0.02830188679245283, 'mean_word_length': 3.135097493036212, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '7425191', 'n_tokens_mistral': 1273, 'n_tokens_neox': 1219, 'n_words': 248}