<commit_before>import qs from 'qs'
import axios from 'axios'
import {copy} from 'copy-paste'
export default shortenUrl

function shortenUrl({
  alias: custom,
  apiKey: api = getApiKey(),
  date,
}) {
  const url = `https://javascriptair.com/episodes/${date}`
  const query = qs.stringify({custom, url, api})
  return axios.get(`https://hive.am/api?${query}`).then(onFinished, onFailure)
}

function getApiKey() {
  try {
    return require('./hive.api.ignored.json').key
  } catch (e) {
    throw new Error('you must provide an API key or have a hive.api.ignored.json')
  }
}

function onFinished(response) {
  const {data: {error, short}} = response
  const NO_ERROR = 0
  if (error !== NO_ERROR) {
    onFailure(response)
  }
  return new Promise((resolve, reject) => {
    copy(short, (err) => {
      if (err) {
        reject(err)
      }
      console.log(`short url created. ${short} copied to your clipboard`)
      resolve(short)
    })
  })
}

function onFailure(rejection) {
  console.error('There was a failure :-(')
  console.error(rejection)
  return Promise.reject(rejection)
}
<commit_msg>Let's have CloudFlare redirect to HTTPS instead and just use HTTP, just in case ¯\_(ツ)_/¯<commit_after>import qs from 'qs'
import axios from 'axios'
import {copy} from 'copy-paste'
export default shortenUrl

function shortenUrl({
  alias: custom,
  apiKey: api = getApiKey(),
  date,
}) {
  const url = `http://javascriptair.com/episodes/${date}`
  const query = qs.stringify({custom, url, api})
  return axios.get(`https://hive.am/api?${query}`).then(onFinished, onFailure)
}

function getApiKey() {
  try {
    return require('./hive.api.ignored.json').key
  } catch (e) {
    throw new Error('you must provide an API key or have a hive.api.ignored.json')
  }
}

function onFinished(response) {
  const {data: {error, short}} = response
  const NO_ERROR = 0
  if (error !== NO_ERROR) {
    onFailure(response)
  }
  return new Promise((resolve, reject) => {
    copy(short, (err) => {
      if (err) {
        reject(err)
      }
      console.log(`short url created. ${short} copied to your clipboard`)
      resolve(short)
    })
  })
}

function onFailure(rejection) {
  console.error('There was a failure :-(')
  console.error(rejection)
  return Promise.reject(rejection)
}

{'fraction_non_alphanumeric': 0.14779186707477043, 'fraction_numerical': 0.0008745080891998251, 'mean_word_length': 3.5306930693069307, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 3, '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': '6397006', 'n_tokens_mistral': 782, 'n_tokens_neox': 777, 'n_words': 202}