<commit_before>/* global module, project, server */

module.exports = function(grunt) {
	grunt.registerTask('server', function() {
		var staticConfig = project.server.tasks.static;

		// Server root
		server.server = project.paths.root;

		// Secure mode
		if (staticConfig.https === true) {
			server.https = true;
		}

		// Override auto-detected IP address
		if (project.server.host !== 'auto') {
			server.host = project.server.host;
		}
	});
};<commit_msg>Inject proxy server assets<commit_after>/* global module, project, server, Wee */

module.exports = function(grunt) {
	grunt.registerTask('server', function() {
		var staticConfig = project.server.tasks.static;

		// Server root
		server.server = project.paths.root;

		// Secure mode
		if (staticConfig.https === true) {
			server.https = true;
		}

		// Server asset injection
		if (project.server.inject && project.server.inject.length) {
			var inject = [];

			project.server.inject.forEach(function(file) {
				if (file.slice(-3) == '.js') {
					inject.push('<script src="' + file + '"></script>');
					Wee.serverWatch(file);
				} else if (file.slice(-4) == '.css') {
					inject.push('<link rel="stylesheet" href="' + file + '">');
					Wee.serverWatch(file);
				}
			});

			server.middleware = function(req, res, next) {
				if (req.headers.accept.match(/^text\/html/)) {
					var _write = res.write;

					res.setHeader('Cache-Control', 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0');

					res.write = function(data) {
						_write.call(res, data.toString().replace('</head>', inject.join('') + '</head>'));
					};
				}

				next();
			};
		}

		// Override auto-detected IP address
		if (project.server.host !== 'auto') {
			server.host = project.server.host;
		}
	});
};
{'fraction_non_alphanumeric': 0.1836962590731435, 'fraction_numerical': 0.0027917364600781687, 'mean_word_length': 3.129032258064516, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '3823241', 'n_tokens_mistral': 693, 'n_tokens_neox': 584, 'n_words': 118}