Skip to content

Do not format a hex price string as zero - #151

Open
SashaMIT wants to merge 1 commit into
iyzico:masterfrom
SashaMIT:codered-hex-price
Open

SashaMIT wants to merge 1 commit into
iyzico:masterfrom
SashaMIT:codered-hex-price

Conversation

@SashaMIT

Copy link
Copy Markdown

Summary

formatPrice is used for payment, refund, and basket prices. isFinite("0x10") is true because Number("0x10") is 16, then parseFloat("0x10") stops at x and the function returned 0.0.

A plain price such as 22 is still 22.0. A non-finite value is still returned unchanged.

Test plan

  • Before the change, formatPrice("0x10") was 0.0
  • npx mocha test/unit/UtilsTest.js passes after the change (16 passing), including the new case that 0x10 stays 0x10

Made with Cursor

parseFloat stops at x, so 0x10 became 0.0 on the payment amount path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant