fix: incorrect type check for number in request params

This commit is contained in:
alikia2x (寒寒) 2025-03-31 06:02:07 +08:00
parent 28772fcd9f
commit 9c0783c607
Signed by: alikia2x
GPG Key ID: 56209E0CCD8420C6
2 changed files with 4 additions and 4 deletions

View File

@ -17,4 +17,4 @@ export default {
fetch,
} satisfies Deno.ServeDefaultExport;
export const VERSION = "0.2.0";
export const VERSION = "0.2.1";

View File

@ -15,9 +15,9 @@ const SnapshotQueryParamsSchema = object({
const idSchema = mixed().test(
"is-valid-id",
'id must be a string starting with "av" followed by digits, or "BV" followed by 10 alphanumeric characters, or a positive integer',
(value) => {
if (typeof value === "number") {
return Number.isInteger(value) && value > 0;
async (value) => {
if (value && await number().isValid(value)) {
return Number.isInteger(value) && (value as number) > 0;
}
if (typeof value === "string") {