astro
Version:
Astro is a modern site builder with web best practices, performance, and DX front-of-mind.
18 lines (17 loc) • 579 B
JavaScript
function matchRoute(pathname, manifest) {
const decodedPathname = decodeURI(pathname);
return manifest.routes.find((route) => {
return route.pattern.test(decodedPathname) || route.fallbackRoutes.some((fallbackRoute) => fallbackRoute.pattern.test(decodedPathname));
});
}
function matchAllRoutes(pathname, manifest) {
return manifest.routes.filter((route) => route.pattern.test(decodeURI(pathname)));
}
function isRoute404or500(route) {
return route.pattern.test("/404") || route.pattern.test("/500");
}
export {
isRoute404or500,
matchAllRoutes,
matchRoute
};