<commit_before>// http://res.cloudinary.com/demo/image/upload/f_auto,q_auto,w_250,h_250,c_fit/sample.jpg
const defaultState = 'f_auto,q_auto,fl_lossy';

export default (url, { mode, maxWidth, maxHeight, width, height, cropX, cropY, quality, blur, retina } = {}, crop) => {
  if (!mode) mode = 'fill';
  if (retina && width) width *= 2;
  if (retina && height) height *= 2;
  if (retina && maxWidth) maxWidth *= 2;
  if (retina && maxHeight) maxHeight *= 2;
  if (!url) return url;
  if (crop) {
    width = crop[0];
    height = crop[1];
    cropX = crop[2];
    cropY = crop[3];
  }
  if (url.indexOf('http://res.cloudinary.com/') === 0) {
    url = url.split('ttp://res.cloudinary.com/').join('ttps://res.cloudinary.com/');
  }
  if (url.indexOf('https://res.cloudinary.com/') !== 0) return url;
  let part = defaultState;
  if (cropX !== undefined && cropY !== undefined) {
    part = `x_${cropX},y_${cropY},w_${width},h_${height},c_crop/${part}`;
  } else if (width && height) {
    part = `w_${width},h_${height},c_${mode}/${part}`;
  }

  if (maxWidth || maxHeight) {
    if (maxWidth) part += `,w_${maxWidth}`;
    if (maxHeight) part += `,h_${maxHeight}`;
    part += `,c_${mode}`;
  }
  if (quality) {
    part += `,q_${quality}`;
  }
  if (blur) {
    part += `,e_blur:${blur}`;
  }
  if (part === defaultState) {
    part += ',q_75';
  }

  return url.replace('/upload/', `/upload/${part}/`);
};<commit_msg>Allow borders in cloudinary-url<commit_after>// http://res.cloudinary.com/demo/image/upload/f_auto,q_auto,w_250,h_250,c_fit/sample.jpg
const defaultState = 'f_auto,q_auto,fl_lossy';

export default (url, { mode, maxWidth, maxHeight, border, width, height, cropX, cropY, quality, blur, retina } = {}, crop) => {
  if (!mode) mode = 'fill';
  if (retina && width) width *= 2;
  if (retina && height) height *= 2;
  if (retina && maxWidth) maxWidth *= 2;
  if (retina && maxHeight) maxHeight *= 2;
  if (!url) return url;
  if (crop) {
    width = crop[0];
    height = crop[1];
    cropX = crop[2];
    cropY = crop[3];
  }
  if (url.indexOf('http://res.cloudinary.com/') === 0) {
    url = url.split('ttp://res.cloudinary.com/').join('ttps://res.cloudinary.com/');
  }
  if (url.indexOf('https://res.cloudinary.com/') !== 0) return url;
  let part = defaultState;
  if (cropX !== undefined && cropY !== undefined) {
    part = `x_${cropX},y_${cropY},w_${width},h_${height},c_crop/${part}`;
  } else if (width && height) {
    part = `w_${width},h_${height},c_${mode}/${part}`;
  }

  if (maxWidth || maxHeight) {
    if (maxWidth) part += `,w_${maxWidth}`;
    if (maxHeight) part += `,h_${maxHeight}`;
    part += `,c_${mode}`;
  }
  if (quality) {
    part += `,q_${quality}`;
  }
  if (blur) {
    part += `,e_blur:${blur}`;
  }
  if (part === defaultState) {
    part += ',q_75';
  }
  if (border) {
    Object.keys(border).map((key) => {
      part = `bo_${border[key]}px_solid_${key}/${part}`;
    });
  }

  return url.replace('/upload/', `/upload/${part}/`);
};
{'fraction_non_alphanumeric': 0.2287340924313463, 'fraction_numerical': 0.012056262558606833, 'mean_word_length': 3.4984939759036147, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 2, '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': '2198136', 'n_tokens_mistral': 1199, 'n_tokens_neox': 1189, 'n_words': 233}