<commit_before>// Defining helper functions
function info(message){
  console.log(message.blue);
}
function danger(message){
  console.log(message.red);
}
function warn(message){
  console.log(message.yellow.bold);
}
function success(message){
  console.log(message.green.bold);
}
function log(message){
  console.log(message);
}
function title(message){
  var title='';
  function getStars(messsage){
    var ret = '';
    for(var i=0; i<messsage.length+6; i++){
      ret+='*';
    }
    return ret;
  }
  title += getStars(message) + '\n';
  title += '** ' + message + ' **\n';
  title += getStars(message);
  return title;
}

// Requiring dependencies
require('colors');
var pkg = require('./package.json');
var express = require('express');
var cli = require('commander');
var open = require('open');
var fs = require('fs');
var jade = require('jade');

// Initializations
var app = express();
var tmp = '', stars = '', url='';
// Default options
var options = {
  port: process.env.PORT || 8080,
  dir: process.cwd(),
  browser: undefined
}

// Defining and parsing CLI options
cli.version(pkg.version)
.option('-d --dir <directory>','directory to serve (default: .)')
.option('-b --browser <browser name>','browser which open served directory')
.option('-p --port <port>','http port to serve to (default: 8080)')
.option('-r --remote','don\'t automatically lauch browser on  localhost (useful if running on _r_emote host)')
.option('-s --stop-on-close','automatically stop the server when user close the browser')
.parse(process.argv);

// Setting options
if (cli.port)       options.port = cli.port;
if (cli.dir)        options.dir = cli.dir;
if (cli.browser)    options.browser = cli.browser;
if (cli.remote)     options.remote = cli.remote;

// Logging CLI user friendly messages
info(title('autostatic-server v' + pkg.version))
info('* serving directory ' + options.dir);
info('* on port ' + options.port);
if(!options.remote) info('* via ' + (options.browser || 'your default') + ' browser');
info('**');
info('* run $ autostatic --help to get command line option informations');
info('**');

app.use(function(req,res,next){
  if (req.path==='/favicon.ico') log(req.path);
  else info(req.path);
  return next();
});
app.use(express.static(options.dir));

app.use(function(req,res,next){
  var filePath = options.dir + req.path;
  require('fs').exists(filePath, function(exists){
    if(!exists)  return res.status(404).send();

    fs.stat(filePath, function(err,stats){<commit_msg>Fix URL encoded path for scanning directories<commit_after>// Defining helper functions
function info(message){
  console.log(message.blue);
}
function danger(message){
  console.log(message.red);
}
function warn(message){
  console.log(message.yellow.bold);
}
function success(message){
  console.log(message.green.bold);
}
function log(message){
  console.log(message);
}
function title(message){
  var title='';
  function getStars(messsage){
    var ret = '';
    for(var i=0; i<messsage.length+6; i++){
      ret+='*';
    }
    return ret;
  }
  title += getStars(message) + '\n';
  title += '** ' + message + ' **\n';
  title += getStars(message);
  return title;
}

// Requiring dependencies
require('colors');
var pkg = require('./package.json');
var express = require('express');
var cli = require('commander');
var open = require('open');
var fs = require('fs');
var jade = require('jade');

// Initializations
var app = express();
var tmp = '', stars = '', url='';
// Default options
var options = {
  port: process.env.PORT || 8080,
  dir: process.cwd(),
  browser: undefined
}

// Defining and parsing CLI options
cli.version(pkg.version)
.option('-d --dir <directory>','directory to serve (default: .)')
.option('-b --browser <browser name>','browser which open served directory')
.option('-p --port <port>','http port to serve to (default: 8080)')
.option('-r --remote','don\'t automatically lauch browser on  localhost (useful if running on _r_emote host)')
.option('-s --stop-on-close','automatically stop the server when user close the browser')
.parse(process.argv);

// Setting options
if (cli.port)       options.port = cli.port;
if (cli.dir)        options.dir = cli.dir;
if (cli.browser)    options.browser = cli.browser;
if (cli.remote)     options.remote = cli.remote;

// Logging CLI user friendly messages
info(title('autostatic-server v' + pkg.version))
info('* serving directory ' + options.dir);
info('* on port ' + options.port);
if(!options.remote) info('* via ' + (options.browser || 'your default') + ' browser');
info('**');
info('* run $ autostatic --help to get command line option informations');
info('**');

app.use(function(req,res,next){
  if (req.path==='/favicon.ico') log(req.path);
  else info(req.path);
  return next();
});
app.use(express.static(options.dir));

app.use(function(req,res,next){
  var filePath = options.dir + decodeURI(req.path);
  require('fs').exists(filePath, function(exists){
    if(!exists)  return res.status(404).send();

    fs.stat(filePath, function(err,stats){
{'fraction_non_alphanumeric': 0.18319093979733758, 'fraction_numerical': 0.0051659050268229685, 'mean_word_length': 4.349628055260362, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, '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': '3881355', 'n_tokens_mistral': 1664, 'n_tokens_neox': 1621, 'n_words': 427}