<commit_before>import { randint } from '../util.js';
import * as cache from './cache.js';
import file from './file.js';
import card from './card.js';
import deck from './deck.js';
import speed from './speed.js';
import collection from './collection.js';
const lut = {
	card,
	deck,
	speed,
	collection,
};
const encodingPref = {
	br: 0,
	gzip: 1,
	deflate: 2,
};
async function forkcorelogic(req, res) {
	res.on('error', () => {});
	const qidx = req.url.indexOf('?'),
		url = ~qidx ? req.url.slice(1, qidx) : req.url.slice(1),
		ifmod = new Date(req.headers['if-modified-since'] ?? '').getTime(),
		acceptedEncodings = (req.headers['accept-encoding'] ?? '')
			.split(',')
			.map(x => x.split(';')[0].trim())
			.sort((x, y) => (encodingPref[x] ?? 3) - (encodingPref[y] ?? 3));
	while (
		acceptedEncodings.length &&
		!encodingPref[acceptedEncodings[acceptedEncodings.length - 1]]
	) {
		acceptedEncodings.pop();
	}
	acceptedEncodings.push('identity');
	if (await cache._try(acceptedEncodings, res, url, ifmod)) return;
	const idx = url.indexOf('/'),
		func = ~idx && lut[url.slice(0, idx)];
	if (func) {
		await cache.add(
			res,
			url,
			ifmod,
			url.slice(idx + 1),
			acceptedEncodings,
			func,
		);
	} else if (
		!~url.indexOf('..') &&
		url.match(/^$|\.(js(on|\.map)?|html?|css|csv|png|ogg|txt)$/)
	) {
		await cache.add(
			res,
			url,
			ifmod,
			url || 'index.html',<commit_msg>Block access to config.json<commit_after>import { randint } from '../util.js';
import * as cache from './cache.js';
import file from './file.js';
import card from './card.js';
import deck from './deck.js';
import speed from './speed.js';
import collection from './collection.js';
const lut = {
	card,
	deck,
	speed,
	collection,
};
const encodingPref = {
	br: 0,
	gzip: 1,
	deflate: 2,
};
async function forkcorelogic(req, res) {
	res.on('error', () => {});
	const qidx = req.url.indexOf('?'),
		url = ~qidx ? req.url.slice(1, qidx) : req.url.slice(1),
		ifmod = new Date(req.headers['if-modified-since'] ?? '').getTime(),
		acceptedEncodings = (req.headers['accept-encoding'] ?? '')
			.split(',')
			.map(x => x.split(';')[0].trim())
			.sort((x, y) => (encodingPref[x] ?? 3) - (encodingPref[y] ?? 3));
	while (
		acceptedEncodings.length &&
		!encodingPref[acceptedEncodings[acceptedEncodings.length - 1]]
	) {
		acceptedEncodings.pop();
	}
	acceptedEncodings.push('identity');
	if (await cache._try(acceptedEncodings, res, url, ifmod)) return;
	const idx = url.indexOf('/'),
		func = ~idx && lut[url.slice(0, idx)];
	if (func) {
		await cache.add(
			res,
			url,
			ifmod,
			url.slice(idx + 1),
			acceptedEncodings,
			func,
		);
	} else if (
		!~url.indexOf('..') &&
		url.match(/^$|(?<!config)\.(js(on|\.map)?|html?|css|csv|png|ogg|txt)$/)
	) {
		await cache.add(
			res,
			url,
			ifmod,
			url || 'index.html',
{'fraction_non_alphanumeric': 0.21709826179496275, 'fraction_numerical': 0.007804185881518269, 'mean_word_length': 3.6305418719211824, 'pattern_counts': {'":': 0, '<': 4, '<?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': '6845233', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1099, 'n_words': 228}