fix: do not capitalize letter after digit in camelCase conversion - #57
Open
Yanhu007 wants to merge 1 commit into
Open
fix: do not capitalize letter after digit in camelCase conversion#57Yanhu007 wants to merge 1 commit into
Yanhu007 wants to merge 1 commit into
Conversation
Previously, every digit-to-letter transition was treated as a word boundary, causing the letter after digits to be capitalized: k8s_version → k8SVersion (wrong, expected k8sVersion) i18n_key → i18NKey (wrong, expected i18nKey) l10n_us → l10NUs (wrong, expected l10nUs) The digit-to-letter transition is not a word boundary in common identifiers like k8s, i18n, l10n. Only explicit delimiters (underscore, space, hyphen, dot) should trigger capitalization. Updated the test expectation for numbers2And55with000 to match the corrected behavior (55with stays lowercase, not 55With). Fixes iancoleman#51
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.
Fixes #51
Problem
ToLowerCamelandToCamelincorrectly capitalize the letter immediately following a digit sequence:k8s_versionk8SVersionk8sVersioni18n_keyi18NKeyi18nKeyl10n_usl10NUsl10nUsThis is because every digit sets
capNext = true, treating digit-to-letter transitions as word boundaries.Fix
Remove
capNext = trueafter digits. Only explicit delimiters (_,,-,.) should trigger word boundaries and capitalization. Alphanumeric identifiers likek8s,i18n,l10nare single words and should not be split at the digit-letter boundary.The test case for
numbers2And55with000was updated to reflect the corrected behavior (55withstays lowercase).All existing tests pass.