fix: replace every $1 in demandCommand min/max messages#2556
Open
patrickwehbe wants to merge 1 commit into
Open
fix: replace every $1 in demandCommand min/max messages#2556patrickwehbe wants to merge 1 commit into
patrickwehbe wants to merge 1 commit into
Conversation
The minMsg/maxMsg templating replaced $0 with a global regex but $1 without one, so only the first $1 in a custom message was substituted and any later $1 was left literal. The docs state every instance of $1 is replaced with the expected count, so make the $1 replace global to match $0 and the documented behavior.
Member
|
(I will rerun tests after #2554 lands to stabilise build.) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The custom
minMsg/maxMsgtemplating indemandCommandreplaces$0with a global regex but$1without one, so only the first$1in a message is substituted and any later$1is left as a literal.The docs say otherwise (docs/api.md): "every instance of
$1will be replaced with the expected value". So the$1replace should be global to match$0and the documented behavior.Before, with
'got $0 ($0), max $1 ($1)':After:
Changed both the min and max branches in
lib/validation.tsand added a test covering repeated tokens. Full suite passes locally.