mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-09-10 19:26:00 +00:00
fix(web): validate ontology pagination (#138)
This commit is contained in:
parent
edf9a1b063
commit
1cfec322ac
6 changed files with 63 additions and 4 deletions
13
apps/logicsrc-web/src/lib/pagination.ts
Normal file
13
apps/logicsrc-web/src/lib/pagination.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
export function parseBoundedIntegerParam(
|
||||
value: string | null,
|
||||
fallback: number,
|
||||
minimum: number,
|
||||
maximum: number
|
||||
): number {
|
||||
const text = value?.trim() ?? "";
|
||||
if (!/^\d+$/.test(text)) return fallback;
|
||||
|
||||
const parsed = Number(text);
|
||||
if (!Number.isSafeInteger(parsed) || parsed < minimum) return fallback;
|
||||
return Math.min(parsed, maximum);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue