diff --git a/src/Humanizer.Tests.Shared/StringHumanizeTests.cs b/src/Humanizer.Tests.Shared/StringHumanizeTests.cs index 6b35eb0d5..e1cfe2177 100644 --- a/src/Humanizer.Tests.Shared/StringHumanizeTests.cs +++ b/src/Humanizer.Tests.Shared/StringHumanizeTests.cs @@ -74,6 +74,7 @@ public void CanHumanizeStringWithAcronyms(string input, string expectedValue) [InlineData("Title_humanization_Honors_ALLCAPS", "Title Humanization Honors ALLCAPS")] [InlineData("MühldorferStraße23", "Mühldorfer Straße 23")] [InlineData("mühldorfer_STRAẞE_23", "Mühldorfer STRAẞE 23")] + [InlineData("CAN RETURN TITLE CASE", "Can Return Title Case")] public void CanHumanizeIntoTitleCase(string input, string expectedResult) { Assert.Equal(expectedResult, input.Humanize(LetterCasing.Title)); diff --git a/src/Humanizer/StringHumanizeExtensions.cs b/src/Humanizer/StringHumanizeExtensions.cs index c25a6a8cd..163eeef04 100644 --- a/src/Humanizer/StringHumanizeExtensions.cs +++ b/src/Humanizer/StringHumanizeExtensions.cs @@ -32,6 +32,12 @@ private static string FromPascalCase(string input) ? match.Value : match.Value.ToLower())); + if (result.Replace(" ", "").ToCharArray().All(c => char.IsUpper(c)) && + result.Contains(" ")) + { + result = result.ToLower(); + } + return result.Length > 0 ? char.ToUpper(result[0]) + result.Substring(1, result.Length - 1) : result; }