Skip to content

Commit 5f30979

Browse files
authored
From kebabed to pascalized fix Issue#1282 (#1299)
1 parent 968ca9e commit 5f30979

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Humanizer.Tests.Shared/InflectorTests.cs

+3
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ public void Hyphenate(string input, string expectedOutput)
123123
[InlineData("customer_first_name goes here", "CustomerFirstNameGoesHere")]
124124
[InlineData("customer name", "CustomerName")]
125125
[InlineData("customer name", "CustomerName")]
126+
[InlineData("customer-first-name", "CustomerFirstName")]
127+
[InlineData("_customer-first-name", "CustomerFirstName")]
128+
[InlineData(" customer__first--name", "CustomerFirstName")]
126129
public void Pascalize(string input, string expectedOutput)
127130
{
128131
Assert.Equal(expectedOutput, input.Pascalize());

src/Humanizer/InflectorExtensions.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ public static string Titleize(this string input)
6565
/// By default, pascalize converts strings to UpperCamelCase also removing underscores
6666
/// </summary>
6767
public static string Pascalize(this string input)
68-
{
69-
return Regex.Replace(input, "(?:^|_| +)(.)", match => match.Groups[1].Value.ToUpper());
68+
{
69+
return Regex.Replace(input, @"(?:[ _-]+|^)([a-zA-Z])", match => match.Groups[1].Value.ToUpper());
7070
}
7171

7272
/// <summary>

0 commit comments

Comments
 (0)