added ー char support

This commit is contained in:
Nicolas Constant 2020-07-31 23:16:23 -04:00
parent 4e9e096a65
commit d9a1dc84be
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

@ -43,6 +43,27 @@ namespace BirdsiteLive.Domain.Tests.Tools
#endregion
}
[TestMethod]
public void Extract_SingleHashTag_SpecialChar_Test()
{
#region Stubs
var message = $"Bla!{Environment.NewLine}#COVIDー19";
#endregion
var service = new StatusExtractor(_settings);
var result = service.ExtractTags(message);
#region Validations
Assert.AreEqual(1, result.tags.Length);
Assert.AreEqual("#COVIDー19", result.tags.First().name);
Assert.AreEqual("Hashtag", result.tags.First().type);
Assert.AreEqual("https://domain.name/tags/COVIDー19", result.tags.First().href);
Assert.IsTrue(result.content.Contains("Bla!"));
Assert.IsTrue(result.content.Contains(@"<a href=""https://domain.name/tags/COVIDー19"" class=""mention hashtag"" rel=""tag"">#<span>COVIDー19</span></a>"));
#endregion
}
[TestMethod]
public void Extract_MultiHashTags_Test()
{