<commit_before>import Route from 'route-parser';
import formatRoutes from './formatRoutes';

import type { $RouteConfig } from './Router';

type $MatchedRoute = {|
	params: Object,
	component: ReactClass<*>,
	route?: Object,
	isMiss?: boolean,
|};

const matchRoute = (routeConfig: $RouteConfig, pathname: string): $MatchedRoute => {
	const formattedRoutes = formatRoutes(routeConfig.routes);

	const foundRoute = formattedRoutes.find(({ route }) => {
		return route.match(pathname);
	});

	return foundRoute
		? Object.assign({}, foundRoute, { params: foundRoute.route.match(pathname) })
		: { component: routeConfig.miss, params: {}, isMiss: true };
};

export default matchRoute;

export const matchSingleRoute = (route: string, pathname: string): boolean | Object => {
	const routeMatcher = new Route(route);
	const matched = routeMatcher.match(pathname);

	return matched ? { params: matched } : false;
};<commit_msg>More flowtypes<commit_after>import Route from 'route-parser';
import formatRoutes from './formatRoutes';

import type { $RouteConfig } from './Router';

type $MatchedRoute = {|
	params: Object,
	component: ReactClass<*>,
	route?: Object,
	isMiss?: boolean,
|};

const matchRoute = (routeConfig: $RouteConfig, pathname: string): $MatchedRoute => {
	const formattedRoutes = formatRoutes(routeConfig.routes);

	const foundRoute = formattedRoutes.find(({ route }) => {
		return route.match(pathname);
	});

	return foundRoute
		? Object.assign({}, foundRoute, { params: foundRoute.route.match(pathname) })
		: { component: routeConfig.miss, params: {}, isMiss: true };
};

export default matchRoute;

export const matchSingleRoute = (route: string, pathname: string): boolean | {| params: Object |} => {
	const routeMatcher = new Route(route);
	const matched: Object = routeMatcher.match(pathname);

	return matched ? { params: matched } : false;
};
{'fraction_non_alphanumeric': 0.144617032672737, 'fraction_numerical': 0.0, 'mean_word_length': 5.35374149659864, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '84207', 'n_tokens_mistral': 571, 'n_tokens_neox': 556, 'n_words': 151}