Skip to content

Commit

Permalink
Support currency conversions with lower case currency codes
Browse files Browse the repository at this point in the history
(except for the currency CUP since it clashes with the measurement unit "cup")
  • Loading branch information
heyman committed Jul 4, 2023
1 parent 0c56738 commit a415247
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/currency.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ let currenciesLoaded = false
export async function loadCurrencies() {
const data = await window.heynote.getCurrencyData()
if (!currenciesLoaded)
math.createUnit(data.base, {override:currenciesLoaded, aliases:[]})
math.createUnit(data.base, {override:currenciesLoaded, aliases:[data.base.toLowerCase()]})
Object.keys(data.rates)
.filter(function (currency) {
return currency !== data.base
})
.forEach(function (currency) {
math.createUnit(currency, {
definition: math.unit(1 / data.rates[currency], data.base),
aliases: [],
aliases: currency === "CUP" ? [] : [currency.toLowerCase()], // Lowercase CUP clashes with the measurement unit cup
}, {override: currenciesLoaded})
})
currenciesLoaded = true
Expand Down

0 comments on commit a415247

Please sign in to comment.