<commit_before>var CORS_PROXY = 'http://cors.io/';

var exportWrapper = document.getElementById('export');
var placeholder = document.getElementById('svgPlaceholder');
var info = document.getElementById('info');
var submit = document.getElementById('submit');

var error = function(err) {
  info.innerHTML = "Can't visualize document due to error (error: " +
    err.error + "; reason: " + err.reason + ")";
  submit.removeAttribute('disabled');
  exportWrapper.style.display = 'none';
};

function parseUrl(str) {

  var url = document.createElement('a');
  url.href = str;
  var path = url.pathname.split('/');

  // Remove '' cause by preceeding /
  path.shift();

  url.db = path.shift();
  url.doc = path.join('/');

  url.dbUrl = url.protocol + '//' + url.hostname + '/' + url.db;

  return url;
}

function initDB(dbUrl, callback) {

  new Pouch(dbUrl, function(err, db) {

    // Likely a CORS problem
    if (err && err.status === 0) {
      dbUrl = CORS_PROXY + dbUrl.replace(/^https?:\/\//, '');
      return new Pouch(dbUrl, callback);
    }

    callback(err, db);
  });<commit_msg>(#9) - respect port number<commit_after>var CORS_PROXY = 'http://cors.io/';

var exportWrapper = document.getElementById('export');
var placeholder = document.getElementById('svgPlaceholder');
var info = document.getElementById('info');
var submit = document.getElementById('submit');

var error = function(err) {
  info.innerHTML = "Can't visualize document due to error (error: " +
    err.error + "; reason: " + err.reason + ")";
  submit.removeAttribute('disabled');
  exportWrapper.style.display = 'none';
};

function parseUrl(str) {

  var url = document.createElement('a');
  url.href = str;
  var path = url.pathname.split('/');

  // Remove '' cause by preceeding /
  path.shift();

  url.db = path.shift();
  url.doc = path.join('/');

  url.dbUrl = url.protocol + '//' + url.hostname + ':' + url.port + '/' + url.db;

  return url;
}

function initDB(dbUrl, callback) {

  new Pouch(dbUrl, function(err, db) {

    // Likely a CORS problem
    if (err && err.status === 0) {
      dbUrl = CORS_PROXY + dbUrl.replace(/^https?:\/\//, '');
      return new Pouch(dbUrl, callback);
    }

    callback(err, db);
  });
{'fraction_non_alphanumeric': 0.18018018018018017, 'fraction_numerical': 0.0013513513513513514, 'mean_word_length': 3.4688128772635816, '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': '4162346', 'n_tokens_mistral': 738, 'n_tokens_neox': 717, 'n_words': 166}