Skip to content

Commit

Permalink
Merge pull request #2099 from j0hannesr0th/master
Browse files Browse the repository at this point in the history
fix: yield not set calculation error
  • Loading branch information
christianlupus authored Jan 27, 2024
2 parents 2c492d6 + 407491d commit 3ab99d6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion src/components/RecipeView/RecipeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
<span class="icon-error" />
{{
// 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.")
}}
</div>
</section>
Expand Down
4 changes: 4 additions & 0 deletions src/js/yieldCalculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 3ab99d6

Please sign in to comment.