INNER CODE UNIT · TypeScript
match
Ammaar-Alam/minebench · middleware.ts:110
const match = pathname.match(/^\/leaderboard\/([^/]+)$/);
if (!match) return null;
const rawKey = safeDecodeURIComponent(match[1]);
if (!rawKey) return null;
const canonicalSlug = resolveModelSlug(rawKey);
if (canonicalSlug && canonicalSlug !== rawKey) {
const nextUrl = req.nextUrl.clone();
nextUrl.pathname = `/leaderboard/${encodeURIComponent(canonicalSlug)}`;
return NextResponse.redirect(nextUrl, 308);
}
return null;
}
function isModelDetailPath(pathname: string): boolean {
return /^\/api\/leaderboard\/models\/[^/]+$/.test(pathname);
}