Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffputz committed Apr 27, 2024
2 parents 21a20b2 + 8356968 commit 5dbc075
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/PopForums.Test/Extensions/StringTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@ public void IsEmailTest()
Assert.True("[email protected]".IsEmailAddress());
Assert.True("[email protected]".IsEmailAddress());
Assert.True("[email protected]".IsEmailAddress());
Assert.True("[email protected]".IsEmailAddress());
}

[Fact]
public void IsNoteEmailTest()
{
Assert.False("a@c".IsEmailAddress());
Assert.False("abc@examplecom".IsEmailAddress());
Assert.False("ora.mixedmedia.studio".IsEmailAddress());
Assert.False("a [email protected]".IsEmailAddress());
Assert.False("aa@c a.com".IsEmailAddress());
Assert.False("[email protected]".IsEmailAddress());
Assert.False("aa@coishd!iwe.com".IsEmailAddress());
}

Expand Down
4 changes: 2 additions & 2 deletions src/PopForums/Extensions/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static string GetMD5Hash(this string text, Guid salt)

public static bool IsEmailAddress(this string text)
{
return Regex.IsMatch(text, @"^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$", RegexOptions.IgnoreCase);
return Regex.IsMatch(text, @"^\S+?@([a-z0-9\-\.])+?\.([a-z0-9\-\.])+$", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture);
}

public static string ToUrlName(this string text)
Expand Down Expand Up @@ -87,4 +87,4 @@ public static string Trimmer(this string stringToTrim, int maxLength)
return stringToTrim.Substring(0, maxLength - 13) + "..." +
stringToTrim.Substring(stringToTrim.Length - 10, 10);
}
}
}

0 comments on commit 5dbc075

Please sign in to comment.