fix: quote ambiguous numeric strings starting with . or + (fixes #249) #253
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.
Linked Issue
Closes #249
Description
Fixed a bug where strings starting with
.or+followed by numbers (e.g.,".622","+861") were incorrectly identified as safe to encode without quotes. This caused them to be encoded as raw numeric-like tokens (e.g.,.622,+861), which could be misinterpreted as numbers during decoding in some environments or by other parsers.The fix expands the numeric detection pattern to ensure these ambiguous strings are explicitly quoted in the output.
Type of Change
Changes Made
NUMERIC_LIKE_PATTERNregex in packages/toon/src/shared/validation.ts to include patterns starting with.(optional digits before) and explicit+signs.".622..."and"+861..."are now properly quoted.SPEC Compliance
Testing
Verified the fix with the new regression test: