fix(receipt-import): correct regex for single pack extraction to handle unit formatting

This commit is contained in:
Nils-Johan Gynther
2026-05-03 08:14:35 +02:00
parent f108034742
commit d4769519c2
@@ -81,7 +81,7 @@ function inferPackageDebugFromRawName(rawName: string): {
}
// e.g. "5dl", "1,5l"
const singlePack = /(\d+(?:[\.,]\d+)?)\s*(ml|cl|dl|l|g|kg)\b/i.exec(normalized);
const singlePack = /(\d+(?:[\.,]\d+)?)\s*(ml|cl|dl|l|g|kg)\b/i.exec(normalized.replace(/([\d.,]+)(ml|cl|dl|l|g|kg)\b/i, '$1 $2'));
if (singlePack) {
const qty = Number.parseFloat(singlePack[1].replace(',', '.'));
const unit = singlePack[2].toLowerCase();