Fix Humanize behavior for fully uppercase input#1657
Fix Humanize behavior for fully uppercase input#1657ye-soling wants to merge 2 commits intoHumanizr:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // if input is all capitals (e.g. an acronym) then return it without change | ||
| if (input.All(char.IsUpper)) | ||
| { | ||
| return input; | ||
| input = input.ToLowerInvariant(); | ||
| } |
There was a problem hiding this comment.
Preserve acronyms when input is all uppercase
The new logic lowers any all-uppercase string before humanizing it, so inputs like "HTML" now return "Html" instead of preserving the acronym. This contradicts the documented behavior and existing tests (see StringHumanizeTests expecting HTML for uppercase inputs) and will cause those tests to fail for any fully uppercase token without separators.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Thanks for the suggestion!
The intent of this change is to address issue #1557, where fully
uppercase inputs with separators (e.g. "SPACE SEPARATOR", "WORD_NAME")
were not being humanized correctly.
Preserving acronyms like "HTML" is a valid concern, but handling that
would likely require additional logic and tests. I wanted to keep this
PR focused on the reported issue scope.
|
Hi maintainers, All CI checks have passed now. |
Hi, thanks for the great library!
This PR fixes an issue where Humanize() returned incorrect results
when the input string was fully uppercase.
Uppercase inputs are now normalized instead of being returned early,
making the behavior consistent with lowercase and mixed-case inputs.
Closes #1557.