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
6 changes: 6 additions & 0 deletions CsuChhs.Extensions.Tests/StringExtensionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ public void TestCsvString()
Assert.Equal("string; with; some; commas; apostrophes and double quotes ", stringWithCommas.ToCsvString());
}

[Fact]
public void TestFormattedPhoneWithChars()
{
Assert.Equal("844LMENBRO", "844LMENBRO".ToPhoneNumber());
}

[Fact]
public void TestFormattedPhoneSevenDigits()
{
Expand Down
2 changes: 1 addition & 1 deletion CsuChhs.Extensions/CsuChhs.Extensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>CHHS Application Development Team</Authors>
<Version>1.5.5</Version>
<Version>1.5.6</Version>
<PackageProjectUrl>https://github.com/csu-chhs/CsuChhs.Extensions</PackageProjectUrl>
<Company>College of Health and Human Sciences</Company>
<PackageId>CsuChhs.Extensions</PackageId>
Expand Down
7 changes: 7 additions & 0 deletions CsuChhs.Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ public static string ToPhoneNumber(this string value)
.Replace(")", "")
.Replace("-", "");

// If after we replace chars, we still do not have
// only numbers, return the value.
if(!IsNumeric(phone))
{
return phone;
}

switch (phone.Length)
{
case 7:
Expand Down