Skip to content

Commit

Permalink
fix: Disable number formatting after decimal point (#559)
Browse files Browse the repository at this point in the history
  • Loading branch information
valiafetisov authored Dec 6, 2022
1 parent 0c51938 commit 8acc2e4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/src/helpers/formatToAutomaticDecimalPoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ function limitedValue(value: number | BigNumber): number | BigNumber {

export function formatWithThousandSeparators(value: string): string {
// We choose regex over native JS solutions, as using native solutions only support numbers
return value.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,');
const parts = value.toString().split('.');
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
return parts.join('.');
}

interface formatToAutomaticDecimalPointsOptions {
Expand Down

0 comments on commit 8acc2e4

Please sign in to comment.