<commit_before>var parser = exports = module.exports = {};
var querystring = require('querystring');
var url = require('url');
parser.parse = function(data, encoding) {
	switch(encoding) {
	case 'application/json':
		return JSON.parse(data);
		break;
	case 'application/x-www-form-urlencoded':
		return querystring.parse(data);
		break;
	default:
		return data;
	}
};

parser.parsepath = function(pathurl) {
	var obj = {};
	obj.path = url.parse(pathurl, true).pathname;
	if (obj.path.lastIndexOf('/') === obj.path.length - 1) {
		obj.path = obj.path.slice(0, obj.path.length - 1);
	}
	obj.query = url.parse(pathurl, true).query;
	return obj;
}

parser.parseParams = function(req, swPath, sPath) {
	if (swPath.indexOf(':') !== -1) {
		swPath = swPath.slice(1);
		sPath = sPath.slice(1);
		swPath = swPath.split('/');
		sPath = sPath.split('/');
		if (swPath.length === sPath.length) {
			var parIndexes = [];
			var matched = true;
			for (var j = 0; j < swPath.length; j++) {
				if (swPath[j].indexOf(':') === -1) {
					if (!swPath[j] === sPath[j]) {
						matched = false
					}
				} else {
					parIndexes.push(j);
				}
			}
			if (matched) {
				req.params = {};
				for ( j = 0; j < parIndexes.length; j++) {
					req.params[swPath[parIndexes[j]].slice(1)] = sPath[parIndexes[j]];
				}
				return true;
			}
		}
		return false;
	}
}<commit_msg>add urlparam parser<commit_after>var parser = exports = module.exports = {};
var querystring = require('querystring');
var url = require('url');

parser.parse = function(data, encoding) {
	switch(encoding) {
	case 'application/json':
		return JSON.parse(data);
		break;
	case 'application/x-www-form-urlencoded':
		return querystring.parse(data);
		break;
	default:
		return data;
	}
};

parser.parsepath = function(pathurl) {
	var obj = {};
	obj.path = url.parse(pathurl, true).pathname;
	if (obj.path.lastIndexOf('/') === obj.path.length - 1) {
		obj.path = obj.path.slice(0, obj.path.length - 1);
	}
	obj.query = url.parse(pathurl, true).query;
	return obj;
};

parser.parseParams = function(req, swPath, sPath) {
	if (swPath.indexOf(':') !== -1) {
		swPath = swPath.slice(1);
		sPath = sPath.slice(1);
		swPath = swPath.split('/');
		sPath = sPath.split('/');
		if (swPath.length === sPath.length) {
			var parIndexes = [];
			var matched = true;
			for (var j = 0; j < swPath.length; j++) {
				if (swPath[j].indexOf(':') === -1) {
					if (!swPath[j] === sPath[j]) {
						matched = false
					}
				} else {
					parIndexes.push(j);
				}
			}
			if (matched) {
				req.params = {};
				for ( j = 0; j < parIndexes.length; j++) {
					req.params[swPath[parIndexes[j]].slice(1)] = sPath[parIndexes[j]];
				}
				return true;
			}
		}
		return false;
	}
};
{'fraction_non_alphanumeric': 0.19152854511970535, 'fraction_numerical': 0.007366482504604052, 'mean_word_length': 3.165644171779141, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1720795', 'n_tokens_mistral': 1169, 'n_tokens_neox': 1017, 'n_words': 206}