<commit_before>module.exports = slugify_url;

/* code to be written */
<commit_msg>before test<commit_after>"use strict";

module.exports = slugify_url;

var defaultOptions = {
	slashChar: '!',
	maxLength: 100,
	skipProtocol: true,
	skipUserPass: true
};

function getOptions(_options) {
	if (typeof(_options) !== 'object') {
		return defaultOptions;
	}

	var options = {};
	for (var _key in defaultOptions) {
		if (typeof(_options[_key]) !== 'undefined') {
			options[_key] = _options[_key];
		} else {
			options[_key] = defaultOptions[_key];
		}
	}
	return options;
}

function slugify_url(url, _options) {
	/* Must be a string representation of an URL */
	if (typeof(url) !== 'string') {
		return null;
	}

	var sanitized = url;
	var options = getOptions(_options);
	
	/* skip protocol part */
	if (options.skipProtocol) {
		sanitized = sanitized.replace(/^[\w]+:\/\//, '');
	}
	
	/* skip user/pass part */
	if (options.skipUserPass) {
		sanitized = sanitized.replace(/[\w\-_\.]+(:[^@]+)?@/, '');
	}
	
	/* skip slashes for slashChar */
	sanitized = sanitized.replace(/\//g, options.slashChar);
	
	/* truncate to max length */
	sanitized = sanitized.substr(0, options.maxLength);

	return sanitized;
}

{'fraction_non_alphanumeric': 0.17095435684647303, 'fraction_numerical': 0.0033195020746887966, 'mean_word_length': 3.804780876494024, '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': '6128041', 'n_tokens_mistral': 451, 'n_tokens_neox': 414, 'n_words': 96}