From 9cd9303ae923d92c05f81f3b8c7d00c79c6806c8 Mon Sep 17 00:00:00 2001 From: ye-soling Date: Fri, 12 Dec 2025 23:33:16 +0900 Subject: [PATCH 1/2] Fix Humanize behavior for fully uppercase input --- src/Humanizer/StringHumanizeExtensions.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Humanizer/StringHumanizeExtensions.cs b/src/Humanizer/StringHumanizeExtensions.cs index cf4f24ead..c4b9f02e8 100644 --- a/src/Humanizer/StringHumanizeExtensions.cs +++ b/src/Humanizer/StringHumanizeExtensions.cs @@ -1,4 +1,6 @@ using System.Runtime.InteropServices; +using System.Linq; + namespace Humanizer; @@ -92,7 +94,7 @@ public static string Humanize(this string input) // if input is all capitals (e.g. an acronym) then return it without change if (input.All(char.IsUpper)) { - return input; + input = input.ToLowerInvariant(); } // if input contains a dash or underscore which precedes or follows a space (or both, e.g. freestanding) From 43dc933bb69547f7176bd985339d2ce501538ca5 Mon Sep 17 00:00:00 2001 From: ye-soling Date: Fri, 12 Dec 2025 23:50:00 +0900 Subject: [PATCH 2/2] Handle uppercase inputs with separators while preserving acronyms --- src/Humanizer/StringHumanizeExtensions.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Humanizer/StringHumanizeExtensions.cs b/src/Humanizer/StringHumanizeExtensions.cs index c4b9f02e8..bd0e06c0e 100644 --- a/src/Humanizer/StringHumanizeExtensions.cs +++ b/src/Humanizer/StringHumanizeExtensions.cs @@ -92,10 +92,11 @@ static string FromPascalCase(string input) public static string Humanize(this string input) { // if input is all capitals (e.g. an acronym) then return it without change - if (input.All(char.IsUpper)) - { - input = input.ToLowerInvariant(); - } + if (input.All(char.IsUpper) && + input.Any(c => c == ' ' || c == '_' || c == '-')) + { + input = input.ToLowerInvariant(); + } // if input contains a dash or underscore which precedes or follows a space (or both, e.g. freestanding) // remove the dash/underscore and run it through FromPascalCase