fix(Speed Converter): wrong m/h is in fact mi/h (miles)

Fix #399
This commit is contained in:
ShareVB committed 2026-05-28 09:10:11 +02:00
1 parent fb8a1eb5b1
commit dfb92f2441
2 files changed
+12 -5

No files matched your search

+10 -3
View File
@@ -92,13 +92,20 @@ function update(key: string) {
.value();
}
else {
const converter = unitsconverter[converterType.value](value).from(key);
const mapUnit = (unit: string) => {
// npm units-converter uses wrong symbol for miles per hour, so we need to fix it
if (converterType.value === 'speed' && unit === 'mi/h') {
return 'm/h';
}
return unit;
};
const converter = unitsconverter[converterType.value](value).from(mapUnit(key));
_.chain(units)
.omit(key)
.omit(mapUnit(key))
.forEach(({ unit }) => {
try {
units[unit].ref = converter.to(unit).value;
units[unit].ref = converter.to(mapUnit(unit)).value;
}
catch (e: any) {
units[unit].ref = 0;
@@ -4,10 +4,10 @@ import UnitsConverter from '@/components/UnitsConverter.vue';
const supportedUnits = {
'm/s': 'meter per second',
'km/h': 'kilometer per hour',
'm/h': 'meter per hour',
'mi/h': 'miles per hour',
'knot': 'knot',
'ft/s': 'feet per second',
}; ;
};
</script>
<template>