<commit_before>'use strict';

//====================================================================

var assign = require('lodash.assign');
var forEach = require('lodash.foreach');
var parseUrl = require('url').parse;
var Bluebird = require('bluebird');

// Support browsers.
var WebSocket = (function (root) {
  return (root && 'WebSocket' in root) ?
    root.WebSocket :
    require('ws')
  ;
})(this);

//====================================================================

var notConnected = function () {
  throw new Error('not connected');
};

// Fix URL if necessary.
var fixUrl = function (url) {
  // Add HTTP protocol if missing.
  if (!/^https?:/.test(url)) {
    url = 'http:'+ url;
  }

  url = parseUrl(url);

  // Suffix path with /api/ if missing.
  var path = url.pathname || '';
  if ('/' !== path[path.length - 1]) {
    path += '/';
  }
  if (!/\/api\/$/.test(path)) {
    path += 'api/';
  }

  // Reconstruct the URL.
  return [
    url.protocol, '//',
    url.host,<commit_msg>ws supports browser natively.<commit_after>'use strict';

//====================================================================

var assign = require('lodash.assign');
var Bluebird = require('bluebird');
var forEach = require('lodash.foreach');
var parseUrl = require('url').parse;
var WebSocket = require('ws');

//====================================================================

var notConnected = function () {
  throw new Error('not connected');
};

// Fix URL if necessary.
var fixUrl = function (url) {
  // Add HTTP protocol if missing.
  if (!/^https?:/.test(url)) {
    url = 'http:'+ url;
  }

  url = parseUrl(url);

  // Suffix path with /api/ if missing.
  var path = url.pathname || '';
  if ('/' !== path[path.length - 1]) {
    path += '/';
  }
  if (!/\/api\/$/.test(path)) {
    path += 'api/';
  }

  // Reconstruct the URL.
  return [
    url.protocol, '//',
    url.host,
{'fraction_non_alphanumeric': 0.3157894736842105, 'fraction_numerical': 0.0010526315789473684, 'mean_word_length': 3.3903002309468824, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7523922', 'n_tokens_mistral': 593, 'n_tokens_neox': 566, 'n_words': 147}