Rocky_Mountain_Vending/.pnpm-store/v10/files/63/1749436fab188251ad7ec3bae02be9b60184496b10c884aa6dfa78409d5bb4295386a9236e159d03b793131cb9d60a03ae638f788def8c53a5fb91af799dba
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

42 lines
No EOL
1.7 KiB
Text

import { getRouteMatcher } from '../../../../shared/lib/router/utils/route-matcher';
import { getRouteRegex } from '../../../../shared/lib/router/utils/route-regex';
/**
* A matcher for the prerender manifest.
*
* This class is used to match the pathname to the dynamic route.
*/ export class PrerenderManifestMatcher {
constructor(pathname, prerenderManifest){
this.matchers = Object.entries(prerenderManifest.dynamicRoutes).filter(([source, route])=>{
// If the pathname is a fallback source route, or the source route is
// the same as the pathname, then we should include it in the matchers.
return route.fallbackSourceRoute === pathname || source === pathname;
}).map(([source, route])=>({
source,
route
}));
}
/**
* Match the pathname to the dynamic route. If no match is found, an error is
* thrown.
*
* @param pathname - The pathname to match.
* @returns The dynamic route that matches the pathname.
*/ match(pathname) {
// Iterate over the matchers. They're already in the correct order of
// specificity as they were inserted into the prerender manifest that way
// and iterating over them with Object.entries guarantees that.
for (const matcher of this.matchers){
// Lazily create the matcher, this is only done once per matcher.
if (!matcher.matcher) {
matcher.matcher = getRouteMatcher(getRouteRegex(matcher.source));
}
const match = matcher.matcher(pathname);
if (match) {
return matcher.route;
}
}
return null;
}
}
//# sourceMappingURL=prerender-manifest-matcher.js.map