<commit_before>#! /usr/bin/env node

'use strict';

const request = require('request');
const chalk = require('chalk');

const pkg = require('../package.json');
const outputFormatter = require('./output-formatter');
const args = require('./cli-args');

const url = args._[0]; 
if (!url) {
  console.error('You didn\'t specify a URL');
  process.exit(1);
}

const startTime = Date.now();

console.log(args);

const options = {
  url,
  headers: {
    'User-Agent': `http-tool/${pkg.version}`
  }
};

request(options, (error, response, body) => {
  if (error) {
    if (error.syscall === 'getaddrinfo' && error.errno === 'ENOTFOUND') {
      console.error(`Unable to resolve host ${error.hostname}`);
    } else if (error.syscall === 'connect' && error.errno === 'ECONNREFUSED') {
      console.error(`Unable to connect to ${url}: Connection refused`);<commit_msg>prepend with http if no protocol given<commit_after>#! /usr/bin/env node

'use strict';

const request = require('request');
const chalk = require('chalk');

const pkg = require('../package.json');
const outputFormatter = require('./output-formatter');
const args = require('./cli-args');

let url = args._[0]; 
if (!url) {
  console.error('You didn\'t specify a URL');
  process.exit(1);
} else if (!url.match(/https?:\/\//)) {
  url = `http://${url}`;
}

const startTime = Date.now();

console.log(args);

const options = {
  url,
  headers: {
    'User-Agent': `http-tool/${pkg.version}`
  }
};

request(options, (error, response, body) => {
  if (error) {
    if (error.syscall === 'getaddrinfo' && error.errno === 'ENOTFOUND') {
      console.error(`Unable to resolve host ${error.hostname}`);
    } else if (error.syscall === 'connect' && error.errno === 'ECONNREFUSED') {
      console.error(`Unable to connect to ${url}: Connection refused`);
{'fraction_non_alphanumeric': 0.20088300220750552, 'fraction_numerical': 0.002207505518763797, 'mean_word_length': 3.953551912568306, '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': '2300493', 'n_tokens_mistral': 597, 'n_tokens_neox': 593, 'n_words': 150}