Skip to content

Commit 5ac1144

Browse files
authored
Merge pull request #1624 from kleros/fix(web)/prevent-app-crash-while-input-fractional-PNK
fix(web): prevent app crash when decimal input is <1 & fixed integer overflow
2 parents d722cb2 + 7630d42 commit 5ac1144

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

web/src/utils/commify.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
export function commify(value: string | number): string {
22
const comps = String(value).split(".");
33

4-
if (
5-
comps.length > 2 ||
6-
!comps[0].match(/^-?[0-9]*$/) ||
7-
(comps[1] && !comps[1].match(/^[0-9]*$/)) ||
8-
value === "." ||
9-
value === "-."
10-
) {
11-
return value.toString();
4+
if (!String(value).match(/^-?[0-9]*\.?[0-9]*$/)) {
5+
return "0";
126
}
137

148
// Make sure we have at least one whole digit (0 if none)

0 commit comments

Comments
 (0)