From e33ad2b151eec370c9546c1e87da5428b5d84199 Mon Sep 17 00:00:00 2001 From: Nexus0ps Date: Tue, 2 Jun 2026 13:44:52 -0400 Subject: [PATCH] fix(tags): use parsePaginationParam to clamp popular-tags limit Replaces ad-hoc Math.min/Math.max/parseInt with parsePaginationParam so limit=0 clamps to 1, malformed values fall back to 50, and oversized values cap at 200. Fixes #360 --- src/app/api/tags/popular/route.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/app/api/tags/popular/route.ts b/src/app/api/tags/popular/route.ts index 9536c769..52131f93 100644 --- a/src/app/api/tags/popular/route.ts +++ b/src/app/api/tags/popular/route.ts @@ -1,3 +1,4 @@ +import { parsePaginationParam } from "@/lib/api-pagination"; import { NextRequest, NextResponse } from "next/server"; import { createClient } from "@/lib/supabase/server"; @@ -5,10 +6,7 @@ import { createClient } from "@/lib/supabase/server"; export async function GET(request: NextRequest) { try { const searchParams = request.nextUrl.searchParams; - const limit = Math.min( - Math.max(parseInt(searchParams.get("limit") || "50", 10) || 50, 1), - 200 - ); + const limit = parsePaginationParam(searchParams.get("limit"), 50, 1, 200); const supabase = await createClient();