From bf525371d9669bf62faf3ec2521bc69f52129902 Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Fri, 24 Mar 2023 22:42:50 +0800 Subject: [PATCH] Fix: Apply toPrecision as last step --- server/routers/api-router.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/routers/api-router.js b/server/routers/api-router.js index a36159ca..d2b32600 100644 --- a/server/routers/api-router.js +++ b/server/routers/api-router.js @@ -224,7 +224,7 @@ router.get("/api/badge/:id/uptime/:duration?", cache("5 minutes"), async (reques ); // limit the displayed uptime percentage to four (two, when displayed as percent) decimal digits - const cleanUptime = parseFloat(uptime.toPrecision(4)); + const cleanUptime = (uptime * 100).toPrecision(4); // use a given, custom color or calculate one based on the uptime value badgeValues.color = color ?? percentageToColor(uptime); @@ -235,7 +235,7 @@ router.get("/api/badge/:id/uptime/:duration?", cache("5 minutes"), async (reques labelPrefix, label ?? `Uptime (${requestedDuration}${labelSuffix})`, ]); - badgeValues.message = filterAndJoin([ prefix, `${cleanUptime * 100}`, suffix ]); + badgeValues.message = filterAndJoin([ prefix, cleanUptime, suffix ]); } // build the SVG based on given values