Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import makeMatcher from "wouter-preact/matcher";
import routes from "../routes";
const matcher = makeMatcher();
/**
* Find out what route should be displayed and return it along
* with the parsed parameters from the route's path pattern.
* @param {object} req - polka's request object
*/
export default async req => {
let CurrentRoute, routeParams, route;
for (let index = 0; index < routes.length; index++) {
route = routes[index];
// Find out if the route matches the url.
const [matches, params] = matcher(route.path, req.url);
// Move on if it's determined to not be the current route.