You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
417 B
15 lines
417 B
/**
|
|
* 解析公开列表的 ?page= query:非有限数或 <1 时返回 1;否则返回正整数(float 向下取整)。
|
|
*/
|
|
export function normalizePublicListPage(raw: unknown): number {
|
|
const n =
|
|
typeof raw === "string"
|
|
? Number.parseInt(raw, 10)
|
|
: typeof raw === "number"
|
|
? raw
|
|
: Number.NaN;
|
|
if (!Number.isFinite(n) || n < 1) {
|
|
return 1;
|
|
}
|
|
return Math.floor(n);
|
|
}
|
|
|