Skip to content

Commit c89f9b6

Browse files
committed
replace unicode minus sign with ascii hyphen
1 parent e2c6f83 commit c89f9b6

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

frontend/src/format.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,21 @@ export function localeFormatter(
1616
locale: string | null,
1717
precision = 2,
1818
): (num: number) => string {
19+
let f;
1920
if (locale == null) {
20-
return format(`.${precision.toString()}f`);
21+
f = format(`.${precision.toString()}f`);
22+
} else {
23+
// this needs to be between 0 and 20
24+
const digits = Math.max(0, Math.min(precision, 20));
25+
const fmt = new Intl.NumberFormat(locale.replace("_", "-"), {
26+
minimumFractionDigits: digits,
27+
maximumFractionDigits: digits,
28+
});
29+
f = fmt.format.bind(fmt);
2130
}
22-
// this needs to be between 0 and 20
23-
const digits = Math.max(0, Math.min(precision, 20));
24-
const fmt = new Intl.NumberFormat(locale.replace("_", "-"), {
25-
minimumFractionDigits: digits,
26-
maximumFractionDigits: digits,
27-
});
28-
return fmt.format.bind(fmt);
31+
32+
// replace unicode minus sign with ascii hyphen
33+
return (num) => f(num).replace("−", "-");
2934
}
3035

3136
const formatterPer = format(".2f");

0 commit comments

Comments
 (0)