mirror of
https://github.com/lifegpc/eh-downloader.git
synced 2026-07-08 01:31:00 +08:00
Add exit api
This commit is contained in:
14
server/parse_form.ts
Normal file
14
server/parse_form.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
export async function parse_bool<T extends boolean | null>(
|
||||
value: FormDataEntryValue | null,
|
||||
def: T,
|
||||
): Promise<boolean | T> {
|
||||
if (value === null) return def;
|
||||
const nv = typeof value === "string" ? value : await value.text();
|
||||
const v = nv.toLowerCase();
|
||||
const n = parseInt(v);
|
||||
if (isNaN(n)) {
|
||||
return v === "true";
|
||||
} else {
|
||||
return n !== 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user