<commit_before>'use strict';

const port = 8000;

const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const morgan = require('morgan');
const logger = require('./logger');
const path = require('path');

app.enable('trust proxy');
app.use(morgan(':remote-addr :method :url :status :res[content-length] - :response-time ms', {'stream': logger.stream}));
app.use(express.static(path.resolve(__dirname, '..', 'dist')));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
<commit_msg>Redirect www to non-www<commit_after>'use strict';

const port = 8000;

const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const morgan = require('morgan');
const logger = require('./logger');
const path = require('path');

app.enable('trust proxy');

// Redirect www to non-www
app.use((req, res, next) => {
    if (req.headers.host.slice(0, 4) === 'www.') {
        var newHost = req.headers.host.slice(4);
        return res.redirect(301, req.protocol + '://' + newHost + req.originalUrl);
    }
    next();
});

app.use(morgan(':remote-addr :method :url :status :res[content-length] - :response-time ms', {'stream': logger.stream}));
app.use(express.static(path.resolve(__dirname, '..', 'dist')));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));

{'fraction_non_alphanumeric': 0.20403749098774332, 'fraction_numerical': 0.010093727469358327, 'mean_word_length': 5.2242152466367715, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '2797378', 'n_tokens_mistral': 453, 'n_tokens_neox': 437, 'n_words': 101}