INNER CODE UNIT · TypeScript

safeDecodeURIComponent

Ammaar-Alam/minebench · middleware.ts:100

function safeDecodeURIComponent(value: string): string | null {
  try {
    return decodeURIComponent(value);
  } catch {
    return null;
  }
}

function maybeRedirectToCanonicalModelSlug(req: NextRequest) {
  const { pathname } = req.nextUrl;
  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) {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…