We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents d722cb2 + 7630d42 commit 5ac1144Copy full SHA for 5ac1144
web/src/utils/commify.ts
@@ -1,14 +1,8 @@
1
export function commify(value: string | number): string {
2
const comps = String(value).split(".");
3
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();
+ if (!String(value).match(/^-?[0-9]*\.?[0-9]*$/)) {
+ return "0";
12
}
13
14
// Make sure we have at least one whole digit (0 if none)
0 commit comments