fix(affiliates): clamp offers pagination#323
Conversation
Greptile SummaryThis PR replaces bare
Confidence Score: 5/5Safe to merge — the change is a targeted input-sanitisation fix with no side effects on the query path beyond bounding the range arguments. The parsePaginationParam helper correctly handles every problematic input class (NaN, Infinity, negatives, fractions, overflow-sized floats) and the arithmetic for the Supabase range call is verified by the new regression tests. No pre-existing behaviour is changed for valid inputs. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["GET ?page=X & limit=Y"] --> B["parsePaginationParam(value, default, min, max)"]
B --> C{"value null or empty?"}
C -- Yes --> D["use defaultValue"]
C -- No --> E["Number(value)"]
E --> F{"isFinite?"}
F -- No --> D
F -- Yes --> G["Math.trunc(parsed)"]
D --> G
G --> H["Math.max(result, min)"]
H --> I["Math.min(result, max)"]
I --> J["page in [1, 100_000], limit in [1, 50]"]
J --> K["from = (page-1) x limit, to = from + limit - 1"]
K --> L["query.range(from, to)"]
Reviews (2): Last reviewed commit: "test(affiliates): share offers paginatio..." | Re-trigger Greptile |
Summary
Fixes #322.
Testing