<commit_before>var _ = require('underscore');
var path = require('path');
var url = require('url');
var request = require('request');
var source = require('../lib/source');
var style = require('../lib/style');
var task = require('../lib/task');
var tm = require('../lib/tm');
var queue = require('queue-async');

var middleware = {};

// Normalizes any paths set for id, source in the querystring.
// Addresses mixed forward/backslash characters on windows and non-encoded
// characters like spaces.
middleware.normalizePaths = function(req, res, next) {
    ['id','source','style'].forEach(function(key) {
        if (!req.query[key]) return;
        var uri = tm.parse(req.query[key]);
        req.query[key] = (uri.protocol ? uri.protocol + '//' : '') + uri.dirname;
    });
    ['id','source'].forEach(function(key) {
        if (!req.body || !req.body[key]) return;
        var uri = tm.parse(req.body[key]);
        // The object returned when the url library parses paths from Windows
        // machines (e.g: file://c:\path) has the drive letter as the host<commit_msg>Update path normalization for req.query too<commit_after>var _ = require('underscore');
var path = require('path');
var url = require('url');
var request = require('request');
var source = require('../lib/source');
var style = require('../lib/style');
var task = require('../lib/task');
var tm = require('../lib/tm');
var queue = require('queue-async');

var middleware = {};

// Normalizes any paths set for id, source in the querystring.
// Addresses mixed forward/backslash characters on windows and non-encoded
// characters like spaces.
middleware.normalizePaths = function(req, res, next) {
    ['id','source','style'].forEach(function(key) {
        if (!req.query[key]) return;
        var uri = tm.parse(req.query[key]);
        var is_windows = (req.query[key].indexOf(':\\') >= 0);
        req.query[key] = (uri.protocol ? uri.protocol + '//' : '') + (is_windows ? '' : uri.host) + uri.dirname;
    });
    ['id','source'].forEach(function(key) {
        if (!req.body || !req.body[key]) return;
        var uri = tm.parse(req.body[key]);
        // The object returned when the url library parses paths from Windows
        // machines (e.g: file://c:\path) has the drive letter as the host
{'fraction_non_alphanumeric': 0.18070175438596492, 'fraction_numerical': 0.0004385964912280702, 'mean_word_length': 3.3697318007662833, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '4072861', 'n_tokens_mistral': 676, 'n_tokens_neox': 673, 'n_words': 196}