Skip to content

Conversation

@jaffarkeikei
Copy link

Problem

getRoundedAmount returns values with trailing decimal points when all decimal
digits are zeros after rounding:

  getRoundedAmount('5.00001', 2)  // Returns "5." ❌                             
  getRoundedAmount('10.00', 2)    // Returns "10." ❌                            
  getRoundedAmount('100.0', 1)    // Returns "100." ❌                           

This causes malformed number strings to be displayed in the UI.

Solution

Changed the regex from /0+$/ to /.?0+$/ to also strip the trailing decimal
point when present.

  getRoundedAmount('5.00001', 2)  // Returns "5" ✓                               
  getRoundedAmount('10.00', 2)    // Returns "10" ✓                              
  getRoundedAmount('100.0', 1)    // Returns "100" ✓                             

Testing

Added test case removes trailing decimal point when all decimal digits are
zeros.

@vercel
Copy link

vercel bot commented Jan 27, 2026

@jaffarkeikei is attempting to deploy a commit to the Coinbase Team on Vercel.

A member of the Team first needs to authorize it.

@cb-heimdall
Copy link

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 1
Sum 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants