Skip to content

fix: spread options in fillLetters toRegex path so capture works for letters - #23

Open
Diwak4r wants to merge 1 commit into
jonschlinkert:masterfrom
Diwak4r:fix/letter-regex-capture
Open

fix: spread options in fillLetters toRegex path so capture works for letters#23
Diwak4r wants to merge 1 commit into
jonschlinkert:masterfrom
Diwak4r:fix/letter-regex-capture

Conversation

@Diwak4r

@Diwak4r Diwak4r commented Jul 8, 2026

Copy link
Copy Markdown

Summary

fill with toRegex: true, capture: true, and step > 1 returns an ungrouped alternation for letters (a|c|e) but a correctly grouped one for numbers ((1|3|5)).

Root cause: in fillLetters, the toRegex call nested the options object instead of spreading it:

return toRegex(range, null, { wrap: false, options });

So capture (and every other option) was dropped on the alpha path. The numbers path already spreads ({ wrap: false, ...options }).

Fix

Spread the options to match fillNumbers:

return toRegex(range, null, { wrap: false, ...options });

Test plan

  • Added a regression test asserting fill('a','z',2,{toRegex:true,capture:true}) === '(a|c|e|g|i|k|m|o|q|s|u|w|y)'.
  • npx mocha → 68 passing.

Before fix the new test fails ('a|c|e...' == '(a|c|e...)'); after fix it passes.

…letters

fillLetters nested 'options' instead of spreading it when building a
toRegex string with step > 1, so the capture flag was silently dropped
for the alpha path (it returned 'a|c|e' instead of '(a|c|e)'). The
numbers path already spreads correctly. Mirror that behavior and add a
regression test.
Copilot AI review requested due to automatic review settings July 8, 2026 12:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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