fix(directory): clamp invalid page query values - #307
Conversation
Greptile SummaryThis PR fixes a bug where invalid
Confidence Score: 5/5The change is minimal and correctly handles all invalid page inputs without touching any other logic. The three-line modification is tightly scoped to page-value parsing. All invalid inputs (NaN, zero, negative) now fall back to 1, and an explicit upper cap prevents runaway offsets. The rest of the GET handler and the entire POST handler are untouched. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[GET /api/directory?page=X] --> B["parseInt(raw || '1', 10)"]
B --> C{Number.isFinite AND > 0?}
C -- No --> D[page = 1]
C -- Yes --> E["Math.min(parsedPage, 10_000)"]
E --> F[page = clamped value]
D --> G["offset = (page - 1) * 20"]
F --> G
G --> H["supabase.range(offset, offset + 19)"]
H --> I[Return listings JSON]
Reviews (2): Last reviewed commit: "fix(directory): cap extreme page query v..." | Re-trigger Greptile |
Summary
Fixes #296.
Verification