Skip to content

Conversation

@ye-soling
Copy link

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.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines 94 to 98
// if input is all capitals (e.g. an acronym) then return it without change
if (input.All(char.IsUpper))
{
return input;
input = input.ToLowerInvariant();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ye-soling
Copy link
Author

Hi maintainers,

All CI checks have passed now.
Please let me know if any further changes are needed. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Humanize(), ApplyCase(), and Transform() all produce incorrect result when the input is in UPPERCASE

1 participant