From f126aa15c2efd27cc174011b8eb4e5bfdf27b73c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 9 May 2022 09:01:43 +0200 Subject: [PATCH] Properly handle NaN in Math.min usage MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/ocpp/OCPPServiceUtils.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/charging-station/ocpp/OCPPServiceUtils.ts b/src/charging-station/ocpp/OCPPServiceUtils.ts index 9d7cf620..7a1fde29 100644 --- a/src/charging-station/ocpp/OCPPServiceUtils.ts +++ b/src/charging-station/ocpp/OCPPServiceUtils.ts @@ -9,8 +9,9 @@ export class OCPPServiceUtils { ): number { options.limitationEnabled = options?.limitationEnabled ?? true; options.unitMultiplier = options?.unitMultiplier ?? 1; + const numberValue = isNaN(parseInt(value)) ? Infinity : parseInt(value); return options?.limitationEnabled - ? Math.min(parseInt(value) * options.unitMultiplier, limit) - : parseInt(value) * options.unitMultiplier; + ? Math.min(numberValue * options.unitMultiplier, limit) + : numberValue * options.unitMultiplier; } } -- 2.34.1