Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions src/Humanizer.Tests/InflectorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
10 changes: 10 additions & 0 deletions src/Humanizer/InflectorExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,5 +261,15 @@ public static string Dasherize(this string underscoredWord)
{
return underscoredWord.Replace('_', '-');
}

/// <summary>
/// Replaces underscores with hyphens in the string
/// </summary>
/// <param name="underscoredWord"></param>
/// <returns></returns>
public static string Hyphenate(this string underscoredWord)
{
return Dasherize(underscoredWord);
}
}
}