Support currency conversions with lower case currency codes

(except for the currency CUP since it clashes with the measurement unit "cup")
This commit is contained in:
Jonatan Heyman 2023-07-04 14:12:17 +02:00
parent 0c567384ee
commit a415247e48
1 changed files with 2 additions and 2 deletions

View File

@ -2,7 +2,7 @@ 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
@ -10,7 +10,7 @@ export async function loadCurrencies() {
.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