From d135cec5aef71c4699fda5e0d376ef358aadd9d1 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Fri, 24 Mar 2023 22:22:00 +0000 Subject: [PATCH] fix bug in input validation Signed-off-by: Arthur Lu --- db.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db.js b/db.js index 722a698..6db346b 100644 --- a/db.js +++ b/db.js @@ -45,7 +45,7 @@ function allocateResources (user, resources) { let newdb = {}; Object.assign(newdb, db); Object.keys(resources).forEach((element) => { - if(resources[element] instanceof Number && isFinite(resources[element])) { + if(typeof(resources[element]) === "number" && isFinite(resources[element])) { newdb[user][element] -= resources[element]; } else { @@ -73,7 +73,7 @@ function releaseResources (user, resources) { let newdb = {}; Object.assign(newdb, db); Object.keys(resources).forEach((element) => { - if(resources[element] instanceof Number && isFinite(resources[element]) && resources[element]) { + if(typeof(resources[element]) === "number" && isFinite(resources[element]) && resources[element]) { newdb[user][element] += resources[element]; } else {