Skip to content

Commit

Permalink
avoid ApplyRules for singular when as plural has already matched (#1358)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp authored Feb 16, 2024
1 parent e5cd3c3 commit 20b04bc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Humanizer/Inflections/Vocabulary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,14 @@ public string Singularize(string word, bool inputIsKnownToBePlural = true, bool

// the Plurality is unknown so we should check all possibilities
var asPlural = ApplyRules(plurals, word, false);
var asPluralAsSingular = ApplyRules(singulars, asPlural, false);
if (asPlural == word ||
word + "s" == asPlural ||
asPluralAsSingular != word ||
word + "s" == asPlural)
{
return result ?? word;
}

var asPluralAsSingular = ApplyRules(singulars, asPlural, false);
if (asPluralAsSingular != word ||
result == word)
{
return result ?? word;
Expand Down

0 comments on commit 20b04bc

Please sign in to comment.