From fa1b82bbd65f1f74771d748d6472126b49b95dfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=BCger?= Date: Sat, 8 Nov 2025 11:59:15 +0100 Subject: [PATCH] fix: handle same-unit conversions in tempo converter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix issue where converting BPM to BPM (or any tempo unit to itself) was incorrectly applying the conversion formula instead of returning the same value. Example bug: 120 BPM → BPM was returning 0.008333 instead of 120 Added check: if fromUnit === toUnit, return value unchanged. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- lib/units.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/units.ts b/lib/units.ts index 082d363..fdc7546 100644 --- a/lib/units.ts +++ b/lib/units.ts @@ -104,6 +104,11 @@ export function convertUnit( const isToTempo = toUnit in tempoUnits; if (isFromTempo && isToTempo) { + // Same unit - no conversion needed + if (fromUnit === toUnit) { + return value; + } + const fromAnchor = tempoUnits[fromUnit as keyof typeof tempoUnits].to_anchor; const toAnchor = tempoUnits[toUnit as keyof typeof tempoUnits].to_anchor;