fix: prevent spurious space before capitals inside quotes#84
Open
jmooring wants to merge 1 commit into
Open
Conversation
When toParts encountered an uppercase letter following punctuation (e.g. a quotation mark), it incorrectly split the punctuation and the letter into separate parts. Joining those parts with spaces then produced an erroneous space, e.g. Humanize(`a "B"`) returned `A " B"` instead of `A "B"`. The fix adds a guard to the split-on-uppercase logic: the split is skipped when the current accumulation buffer contains both space-like characters and non-space characters. This situation arises when a quotation mark (or similar punctuation) follows a word boundary; the uppercase letter that follows is the first letter of a quoted word and should remain attached to the surrounding punctuation. The guard preserves all existing behaviour: - camelCase splitting (x has only letters, no space) - identifier separators like _ - : (x has only space-like chars) - leading punctuation like !@# before a word (x has no space) Closes gobuffalo#83 Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
When
toPartsencountered an uppercase letter following punctuation (e.g. a quotation mark), it incorrectly split the punctuation and the letter into separate parts. Joining those parts with spaces then produced an erroneous space, e.g.Humanize(`a "B"`)returnedA " B"instead ofA "B".The fix adds a guard to the split-on-uppercase logic: the split is skipped when the current accumulation buffer contains both space-like characters and non-space characters. This situation arises when a quotation mark (or similar punctuation) follows a word boundary; the uppercase letter that follows is the first letter of a quoted word and should remain attached to the surrounding punctuation.
The guard preserves all existing behavour:
_ - :(x has only space-like chars)!@#before a word (x has no space)Closes #83