<commit_before>var express = require('express');
var router = express.Router();
var shell = require('shelljs');
var fs = require("fs");
var validator = require('validator');
var slug = require('slug');
var md5 = require('md5');
var validLangs = ['en-US', 'en-GB', 'es-ES', 'it-IT', 'de-DE', 'fr-FR'];

function sanitize(input) {
	return input.substring(0, 250).replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, '');;
}

router.get('/', function(req, res, next) {
	return res.render('index', {hostname: req.headers.host, languages : validLangs});
});

router.get('/api/:lang', function(req, res, next) {
	//Generate the audio file
	var lang = req.params.lang.substring(0, 250).replace(/[`~!@#$%^&*()_|+\=?;:'",.<>\{\}\[\]\\\/]/gi, ''); //Different sanitization here
	var text = sanitize(req.query.text);
	var play = sanitize(req.query.play);
	//var fileName = md5(text); //The old way naming
	var fileName = slug(text);<commit_msg>Fixed TTS on same phrase in different languages<commit_after>var express = require('express');
var router = express.Router();
var shell = require('shelljs');
var fs = require("fs");
var validator = require('validator');
var slug = require('slug');
var md5 = require('md5');
var validLangs = ['en-US', 'en-GB', 'es-ES', 'it-IT', 'de-DE', 'fr-FR'];

function sanitize(input) {
	if (!input) return "";
	
	return input.substring(0, 250).replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, '');;
}

router.get('/', function(req, res, next) {
	return res.render('index', {hostname: req.headers.host, languages : validLangs});
});

router.get('/api/:lang', function(req, res, next) {
	//Generate the audio file
	var lang = req.params.lang.substring(0, 250).replace(/[`~!@#$%^&*()_|+\=?;:'",.<>\{\}\[\]\\\/]/gi, ''); //Different sanitization here
	var text = sanitize(req.query.text);
	var play = sanitize(req.query.play);
	//var fileName = md5(text); //The old way naming
	var fileName = slug(text) + "-" + slug(lang);
{'fraction_non_alphanumeric': 0.2662904053360698, 'fraction_numerical': 0.011287839917906618, 'mean_word_length': 4.603448275862069, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '179541', 'n_tokens_mistral': 726, 'n_tokens_neox': 716, 'n_words': 160}