Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/app/feed/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Header } from "@/components/layout/Header";
import { CreatePostForm } from "@/components/feed/CreatePostForm";
import { FeedSortTabs } from "@/components/feed/FeedSortTabs";
import { FeedList } from "@/components/feed/FeedList";
import { parsePageParam } from "@/lib/pagination";
import type { Metadata } from "next";

export const metadata: Metadata = {
Expand All @@ -24,7 +25,7 @@ async function FeedContent({ searchParams }: FeedPageProps) {
const resolvedParams = await searchParams;
const sort = resolvedParams.sort || "hot";
const tag = resolvedParams.tag || undefined;
const page = Number(resolvedParams.page) || 1;
const page = parsePageParam(resolvedParams.page);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Same unsafe pattern exists in two other filessrc/components/search/SearchResults.tsx (line 37) and src/app/api/gigs/route.ts (line 27) still use Number(searchParams.get("page")) || 1, which has the same Infinity-bypass that this PR fixes here. Those pages are not part of this diff but share the identical pre-fix behaviour.


const supabase = await createClient();

Expand Down
2 changes: 2 additions & 0 deletions src/lib/pagination.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ describe("parsePageParam", () => {
expect(parsePageParam("-1")).toBe(1);
expect(parsePageParam("0")).toBe(1);
expect(parsePageParam("abc")).toBe(1);
expect(parsePageParam("Infinity")).toBe(1);
expect(parsePageParam("-Infinity")).toBe(1);
});

it("truncates fractional page values", () => {
Expand Down
Loading