<commit_before>var express = require('express')
  , _ = require('underscore')
  , Host = require('./host')
  ;

var server = express();
server.set('basePath', __dirname+"/../..");

server.config = require(server.set('basePath')+"/config.json");

server.use('/core/lib', express.static(server.set('basePath') + '/core/frontend/lib', {maxAge: server.set('staticMaxAge')}));
server.use('/core/js', express.static(server.set('basePath') + '/core/frontend/js', {maxAge: server.set('staticMaxAge')}));
server.use('/core/css', express.static(server.set('basePath') + '/core/frontend/css', {maxAge: server.set('staticMaxAge')}));

// Master website
require('./server')(server);

// Hosts
server.use(function(req, res, next) {

  _.each(server.config.repositories,function(repo) {
    // We make sure the request url ends with "/" since loading css and js is relative
    if(req.url.match(new RegExp('/'+repo.path+'$','i'))) return res.redirect(req.url+'/');

    // We route the request to the appropriate host
    if(req.header('host').match(new RegExp(repo.host+'(:[0-9]+)?','i')))
      req.url = '/'+repo.path+req.url;
  });
  next();
});

// We start an expressjs server for each route and mount it on /repo.path
_.each(server.config.repositories,function(repo) {
  console.log("Instantiating new host for ", repo);
  var host = new Host(repo);
  server.use('/'+repo.path, host);
});
<commit_msg>Fix for routing to right host<commit_after>var express = require('express')
  , _ = require('underscore')
  , Host = require('./host')
  ;

var server = express();
server.set('basePath', __dirname+"/../..");

server.config = require(server.set('basePath')+"/config.json");

server.use('/core/lib', express.static(server.set('basePath') + '/core/frontend/lib', {maxAge: server.set('staticMaxAge')}));
server.use('/core/js', express.static(server.set('basePath') + '/core/frontend/js', {maxAge: server.set('staticMaxAge')}));
server.use('/core/css', express.static(server.set('basePath') + '/core/frontend/css', {maxAge: server.set('staticMaxAge')}));

// Hosts
server.use(function(req, res, next) {

  if(req.url.match(/webhooks\/github/)) return next();

  _.each(server.config.repositories,function(repo) {
    // We make sure the request url ends with "/" since loading css and js is relative
    if(req.url.match(new RegExp('/'+repo.path+'$','i'))) return res.redirect(req.url+'/');

    // We route the request to the appropriate host
    if(req.header('host').match(new RegExp(repo.host+'(:[0-9]+)?','i')))
      req.url = '/'+repo.path+req.url;
  });
  next();
});

// Master website
require('./server')(server);

// We start an expressjs server for each route and mount it on /repo.path
_.each(server.config.repositories,function(repo) {
  console.log("Instantiating new host for ", repo);
  var host = new Host(repo);
  server.use('/'+repo.path, host);
});

{'fraction_non_alphanumeric': 0.2144856543037089, 'fraction_numerical': 0.0013995801259622112, 'mean_word_length': 4.540697674418604, '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': '1263534', 'n_tokens_mistral': 967, 'n_tokens_neox': 941, 'n_words': 194}