<commit_before>var path = require("path");
var utils    = require("utils-pkg");

/**
 * Parse options of the package
 * 
 * @param  {Object} opts Options given from the server
 * @return {Object}      Options object merged with default
 */
module.exports.parseOptions = function(opts){
	if(utils.isFalsy(opts)){
		throw new Error("Options is undefined");
	}

	else if(!utils.isObject(opts)){
		throw new Error("Options parameter must be an object");
	}

	else{
		// Path is mandatory for this package, throw error if undefined
		if(!opts.path){
			throw new Error("Path for static files is undefined");
		}

		return {
			path: path.resolve(opts.path),
			index: opts.index !== undefined ? this.resolveIndex(opts.index) : "index",
			defaultExtension: opts.defaultExtension || "html",
			cache: opts.cache || "max-age=3600",
			scriptName: opts.scriptName !== undefined ? opts.scriptName : false
		};
	}
}

/**
 * Give or replace extension file with a directory
 * 
 * @param {String} dir The normal directory
 * @param {String} ext The new directory with the given extension
 */
module.exports.setExtension = function(dir, ext){<commit_msg>FIX: bug parseOptions<commit_after>var path = require("path");
var utils    = require("utils-pkg");

/**
 * Parse options of the package
 * 
 * @param  {Object} opts Options given from the server
 * @return {Object}      Options object merged with default
 */
module.exports.parseOptions = function(opts){
	if(typeof opts == "undefined"){
		throw new Error("Options is undefined");
	}

	else if(!utils.isObject(opts)){
		throw new Error("Options parameter must be an object");
	}

	else{
		// Path is mandatory for this package, throw error if undefined
		if(!opts.path){
			throw new Error("Path for static files is undefined");
		}

		return {
			path: path.resolve(opts.path),
			index: opts.index !== undefined ? this.resolveIndex(opts.index) : "index",
			defaultExtension: opts.defaultExtension || "html",
			cache: opts.cache || "max-age=3600",
			scriptName: opts.scriptName !== undefined ? opts.scriptName : false
		};
	}
}

/**
 * Give or replace extension file with a directory
 * 
 * @param {String} dir The normal directory
 * @param {String} ext The new directory with the given extension
 */
module.exports.setExtension = function(dir, ext){
{'fraction_non_alphanumeric': 0.12973443622115804, 'fraction_numerical': 0.0034828036569438396, 'mean_word_length': 3.963282937365011, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4350305', 'n_tokens_mistral': 707, 'n_tokens_neox': 655, 'n_words': 223}