Skip to content

Commit

Permalink
fix(NumberFormat): should not throw exception when providing an inval…
Browse files Browse the repository at this point in the history
…id currency (#4192)
  • Loading branch information
langz authored Oct 29, 2024
1 parent 3ace8b0 commit a0700cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ const prepareMinus = (display, locale) => {
* @returns {string} The aligned output string.
*/
function alignCurrencySymbol(output, currencyDisplay) {
if (currencyDisplay === 'name') {
if (typeof output === 'string' && currencyDisplay === 'name') {
output = output.replace(/(nor[^\s]+?)\s(\w+)/i, '$2')
}
return output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ describe('Decimals format', () => {
decimals: undefined,
})
).toBe('-1,1234567891234568')
expect(format(null, { currency: 'non-valid value' })).toBe('null')
expect(format(undefined, { currency: 'non-valid value' })).toBe(
'undefined'
)
})

describe('rounding', () => {
Expand Down

0 comments on commit a0700cd

Please sign in to comment.