<commit_before>const PARAMETER_REGEXP = /([:*])(\w+)/g;
const WILDCARD_REGEXP = /\*/g;
const REPLACE_VARIABLE_REGEXP = '([^\/]+)';
const REPLACE_WILDCARD = '(?:.*)';
const FOLLOWED_BY_SLASH_REGEXP = '(?:\/$|$)';
const MATCH_REGEXP_FLAGS = '';
let _routes = [];

export function add(routes) {
	routes.forEach(route => {
		_routes.push(route);
	});
}

export default {
	map(routes) {
		add(routes);
	},
	routes(index) {
		if (index && _routes[index]) {
			return _routes[index];
		}

		return _routes;
	}
};<commit_msg>Add parse url function<commit_after>import { $unserialize } from 'core/types';
import { _doc } from 'core/variables';

const PARAMETER_REGEXP = /([:*])(\w+)/g;
const WILDCARD_REGEXP = /\*/g;
const REPLACE_VARIABLE_REGEXP = '([^\/]+)';
const REPLACE_WILDCARD = '(?:.*)';
const FOLLOWED_BY_SLASH_REGEXP = '(?:\/$|$)';
const MATCH_REGEXP_FLAGS = '';
const REMOVE_SLASHES_REGEXP = /^\/|\/$/g;
let _routes = [];

/**
 * Add a route to routes array
 *
 * @private
 * @param routes
 */
function _add(routes) {
	routes.forEach(route => {
		_routes.push(route);
	});
}

/**
 * Parse url and return results
 *
 * @private
 * @param value
 * @returns {{full: string, hash: (Blob|string|*|ArrayBuffer|Array.<T>|$), path: string, query: {}, segments: Array, url: (*|Location|String|string), port}}
 * @private
 */
function _parseUrl(value) {
	const a = _doc.createElement('a');
	a.href = value || window.location;

	const search = a.search,
		path = a.pathname.replace(REMOVE_SLASHES_REGEXP, '');

	return {
		full: '/' + path + search + a.hash,
		hash: a.hash.slice(1),
		path: '/' + path,
		query: search ? $unserialize(search) : {},
		segments: path.split('/'),
		url: a.href,
		port: a.port
	};
}

export default {
	map(routes) {
		_add(routes);

		return this;
	},
	routes(index) {
		if (index && _routes[index]) {
			return _routes[index];
		}

		return _routes;
	},
	run() {
		//
	},
	uri(value) {
		return _parseUrl(value);
	}
};
{'fraction_non_alphanumeric': 0.20350334878928386, 'fraction_numerical': 0.0005151983513652757, 'mean_word_length': 3.9794871794871796, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, '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': '6577286', 'n_tokens_mistral': 785, 'n_tokens_neox': 774, 'n_words': 147}