Skip to content

Commit

Permalink
fix(NumberFormat): not break code when not providing a currency
Browse files Browse the repository at this point in the history
  • Loading branch information
langz committed Oct 29, 2024
1 parent 9b38904 commit bdce6b9
Show file tree
Hide file tree
Showing 2 changed files with 4 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 (output && 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,9 @@ 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('null')
})

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

0 comments on commit bdce6b9

Please sign in to comment.