Skip to content

Commit

Permalink
Merge pull request louislam#2973 from chakflying/fix/limit-precision
Browse files Browse the repository at this point in the history
Fix: Apply toPrecision as last step
  • Loading branch information
louislam authored Mar 26, 2023
2 parents 41bda4e + bf52537 commit fbdeb30
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/routers/api-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,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);
Expand All @@ -239,7 +239,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
Expand Down

0 comments on commit fbdeb30

Please sign in to comment.