Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/Humanizer/StringHumanizeExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Runtime.InteropServices;
using System.Linq;


namespace Humanizer;

Expand Down Expand Up @@ -90,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))
{
return input;
}
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
Expand Down
Loading