Skip to content

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

Closed
Jitmisra wants to merge 1 commit into
joplin:masterfrom
Jitmisra:fix/repeat-helper-raw-num-bug
Closed

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

Conversation

@Jitmisra

Copy link
Copy Markdown
Contributor

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 < rawNum → i < num in the for loop (line 12)

Testing

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

@Jitmisra
Jitmisra force-pushed the fix/repeat-helper-raw-num-bug branch from c142931 to 730cd3d Compare March 1, 2026 08:43
@alondmnt

Copy link
Copy Markdown
Collaborator

Thanks for spotting this @Jitmisra, your diagnosis was right. We're going with #128 for the same fix, since it links the issue and has already been through review. Closing this as a duplicate.

If you'd like another one, #105 (a notebook_name template variable) is small and self-contained.

@alondmnt alondmnt closed this Sep 16, 2026
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.

2 participants