added special char

This commit is contained in:
Nicolas Constant 2020-07-31 23:11:41 -04:00
parent 8643f3d366
commit 4fa8b1ade2
No known key found for this signature in database
GPG key ID: 1E9F677FB01A5688
2 changed files with 23 additions and 2 deletions

View file

@ -12,8 +12,8 @@ namespace BirdsiteLive.Domain.Tools
public class StatusExtractor : IStatusExtractor
{
private readonly Regex _hastagRegex = new Regex(@"\W(\#[a-zA-Z0-9]+\b)(?!;)");
private readonly Regex _mentionRegex = new Regex(@"\W(\@[a-zA-Z0-9]+\b)(?!;)");
private readonly Regex _hastagRegex = new Regex(@"\W(\#[a-zA-Z0-9_]+\b)(?!;)");
private readonly Regex _mentionRegex = new Regex(@"\W(\@[a-zA-Z0-9_]+\b)(?!;)");
private readonly InstanceSettings _instanceSettings;
#region Ctor

View file

@ -84,6 +84,27 @@ namespace BirdsiteLive.Domain.Tests.Tools
#endregion
}
[TestMethod]
public void Extract_SingleMentionTag_SpecialChar_Test()
{
#region Stubs
var message = $"Bla!{Environment.NewLine}@my___nickname";
#endregion
var service = new StatusExtractor(_settings);
var result = service.ExtractTags(message);
#region Validations
Assert.AreEqual(1, result.tags.Length);
Assert.AreEqual("@my___nickname@domain.name", result.tags.First().name);
Assert.AreEqual("Mention", result.tags.First().type);
Assert.AreEqual("https://domain.name/users/my___nickname", result.tags.First().href);
Assert.IsTrue(result.content.Contains("Bla!"));
Assert.IsTrue(result.content.Contains(@"<span class=""h-card""><a href=""https://domain.name/@my___nickname"" class=""u-url mention"">@<span>my___nickname</span></a></span>"));
#endregion
}
[TestMethod]
public void Extract_MultiMentionTag_Test()
{