diff --git a/src/Humanizer.Tests/InflectorTests.cs b/src/Humanizer.Tests/InflectorTests.cs index 13d452e92..dc68f54f4 100644 --- a/src/Humanizer.Tests/InflectorTests.cs +++ b/src/Humanizer.Tests/InflectorTests.cs @@ -76,6 +76,16 @@ public void Dasherize(string input, string expectedOutput) Assert.Equal(input.Dasherize(), expectedOutput); } + [InlineData("some_title", "some-title")] + [InlineData("some-title", "some-title")] + [InlineData("some_title_goes_here", "some-title-goes-here")] + [InlineData("some_title and_another", "some-title and-another")] + [Theory] + public void Hyphenate(string input, string expectedOutput) + { + Assert.Equal(input.Hyphenate(), expectedOutput); + } + [Theory] [InlineData("customer", "Customer")] [InlineData("CUSTOMER", "CUSTOMER")] diff --git a/src/Humanizer/InflectorExtensions.cs b/src/Humanizer/InflectorExtensions.cs index a75197f6a..c6019a5d6 100644 --- a/src/Humanizer/InflectorExtensions.cs +++ b/src/Humanizer/InflectorExtensions.cs @@ -261,5 +261,15 @@ public static string Dasherize(this string underscoredWord) { return underscoredWord.Replace('_', '-'); } + + /// + /// Replaces underscores with hyphens in the string + /// + /// + /// + public static string Hyphenate(this string underscoredWord) + { + return Dasherize(underscoredWord); + } } } \ No newline at end of file