Skip to content

Commit

Permalink
fix: support input when it starts with a dot
Browse files Browse the repository at this point in the history
  • Loading branch information
chybisov committed Mar 24, 2023
1 parent 6d294ed commit 80857dd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/widget/src/utils/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ export const formatAmount = (
if (!amount) {
return amount;
}
const formattedAmount = amount.replaceAll(',', '.');
let formattedAmount = amount.replaceAll(',', '.');
if (formattedAmount.startsWith('.')) {
formattedAmount = '0' + formattedAmount;
}
const parsedAmount = parseFloat(formattedAmount);
if (isNaN(Number(formattedAmount)) && !isNaN(parsedAmount)) {
return parsedAmount.toString();
Expand Down

0 comments on commit 80857dd

Please sign in to comment.