From 8ce4865d045d979358f3dc9531b3fed23ef2ef25 Mon Sep 17 00:00:00 2001 From: Yufan Sheng Date: Tue, 12 Nov 2024 15:19:17 +0800 Subject: [PATCH] fix: invalid input syntax for type bigint "NaN" --- src/pages/avatar/[hash].webp.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/avatar/[hash].webp.ts b/src/pages/avatar/[hash].webp.ts index 178a2c1..9219f56 100644 --- a/src/pages/avatar/[hash].webp.ts +++ b/src/pages/avatar/[hash].webp.ts @@ -8,7 +8,7 @@ const defaultAvatar = (): string => { }; function isNumeric(str: string) { - return !Number.isNaN(str) && !Number.isNaN(Number.parseFloat(str)); + return /^-?\d+$/.test(str); } const avatarImage = async ( @@ -42,7 +42,7 @@ export const GET: APIRoute = async ({ params, redirect }) => { // This is a existed user. if (isNumeric(hash)) { - const email = await queryEmail(Number(hash)); + const email = await queryEmail(Number.parseInt(hash)); if (email === null) { return redirect(defaultAvatar()); }