Skip to content

Commit

Permalink
fix(CurrencyConversion): correctly transform base and target to lower…
Browse files Browse the repository at this point in the history
…case
  • Loading branch information
oliverschwendener committed Feb 20, 2024
1 parent 41e8cba commit efb2ad0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/Extensions/CurrencyConversion/CurrencyConversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ export class CurrencyConversion implements Extension {
const validators = [
() => parts.length === 4,
() => !isNaN(Number(parts[0])),
() => Object.keys(this.rates).includes(parts[1]),
() => Object.keys(this.rates).includes(parts[1].toLowerCase()),
() => ["in", "to"].includes(parts[2].toLowerCase()),
() => Object.keys(this.rates[parts[1]]).includes(parts[3]),
() => Object.keys(this.rates[parts[1].toLowerCase()]).includes(parts[3].toLowerCase()),
];

for (const validator of validators) {
Expand Down Expand Up @@ -124,7 +124,7 @@ export class CurrencyConversion implements Extension {
}

private convert({ value, base, target }: { value: number; base: string; target: string }): number {
return value * this.rates[base][target];
return value * this.rates[base.toLowerCase()][target.toLowerCase()];
}

private async setRates(): Promise<void> {
Expand Down

0 comments on commit efb2ad0

Please sign in to comment.