Skip to content

Comments

fix: use parsed number instead of raw string in repeat helper loop#125

Open
Jitmisra wants to merge 1 commit intojoplin:masterfrom
Jitmisra:fix/repeat-helper-raw-num-bug
Open

fix: use parsed number instead of raw string in repeat helper loop#125
Jitmisra wants to merge 1 commit intojoplin:masterfrom
Jitmisra:fix/repeat-helper-raw-num-bug

Conversation

@Jitmisra
Copy link

What

Fixes a bug in the repeat Handlebars helper where the loop condition used the unparsed string argument (rawNum) instead of the parseInt-parsed integer (num).

Why

Although JavaScript's implicit type coercion made the comparison i < rawNum work for typical inputs, using the raw string is semantically incorrect. The parseInt call exists specifically to validate and convert the input — the parsed result num should be used consistently after validation.

Changes

  • src/helpers/repeat.ts: Changed i < rawNumi < num in the for loop (line 12)

Testing

  • All 46 existing unit tests pass ✅
  • No behavioral change for valid numeric inputs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant