Add max_length settings to export zip

This commit is contained in:
2023-06-14 18:18:54 +08:00
parent f46ad802f8
commit 8140a42a47
7 changed files with 43 additions and 6 deletions

View File

@@ -12,3 +12,14 @@ export async function parse_bool<T extends boolean | null>(
return n !== 0;
}
}
export async function parse_int<T extends number | null>(
value: FormDataEntryValue | null,
def: T,
): Promise<number | T> {
if (value === null) return def;
const v = typeof value === "string" ? value : await value.text();
const n = parseInt(v);
if (isNaN(n)) return def;
return n;
}