diff --git a/CHANGELOG.md b/CHANGELOG.md index d86bfc1f3..84a5ea86e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ [#2015](https://github.com/nextcloud/cookbook/pull/2015) @seyfeb - Prevent recalculation algorithm if no yield is given [#2003](https://github.com/nextcloud/cookbook/pull/2003) @j0hannesr0th +- Fix yield not set calculation error + [#2099](https://github.com/nextcloud/cookbook/pull/2099) @j0hannesr0th ### Documentation - Improve structure of `README.md` diff --git a/src/components/RecipeView/RecipeView.vue b/src/components/RecipeView/RecipeView.vue index 577a5aabf..8b34bc30b 100644 --- a/src/components/RecipeView/RecipeView.vue +++ b/src/components/RecipeView/RecipeView.vue @@ -184,7 +184,7 @@ {{ // prettier-ignore - t("cookbook", "The ingredient cannot be recalculated due to incorrect syntax. Please change it to this syntax: amount unit ingredient. Examples: 200 g carrots or 1 pinch of salt") + t("cookbook", "The ingredient cannot be recalculated due to incorrect syntax. Please ensure the syntax follows this format: amount unit ingredient and that a specific number of portions is set for this function to work correctly. Examples: 200 g carrots or 1 pinch of salt.") }} diff --git a/src/js/yieldCalculator.js b/src/js/yieldCalculator.js index f4ce6c5a4..3e0b77899 100644 --- a/src/js/yieldCalculator.js +++ b/src/js/yieldCalculator.js @@ -41,6 +41,10 @@ function recalculateIngredients(ingredients, currentYield, originalYield) { return ingredient; } + if (!Number.isInteger(originalYield) || originalYield < 1) { + return ingredient; + } + const matches = ingredient.match(fractionRegExp); if (matches) {