commit
ce5c843be6
3 changed files with 22 additions and 3 deletions
|
@ -44,6 +44,8 @@ namespace BirdsiteLive.Domain.Tools
|
|||
// Replace return lines
|
||||
messageContent = Regex.Replace(messageContent, @"\r\n\r\n?|\n\n", "</p><p> ");
|
||||
messageContent = Regex.Replace(messageContent, @"\r\n?|\n", "<br/> ");
|
||||
messageContent = Regex.Replace(messageContent, @"\(@", "( @");
|
||||
messageContent = Regex.Replace(messageContent, @"\(#", "( #");
|
||||
|
||||
// Secure emojis
|
||||
var emojiMatch = _emojiRegex.Matches(messageContent);
|
||||
|
@ -83,7 +85,7 @@ namespace BirdsiteLive.Domain.Tools
|
|||
|
||||
// Extract Hashtags
|
||||
var hashtagMatch = OrderByLength(_hastagRegex.Matches(messageContent));
|
||||
foreach (Match m in hashtagMatch)
|
||||
foreach (Match m in hashtagMatch.OrderByDescending(x => x.Length))
|
||||
{
|
||||
var tag = m.ToString().Replace("#", string.Empty).Replace("\n", string.Empty).Trim();
|
||||
var url = $"https://{_instanceSettings.Domain}/tags/{tag}";
|
||||
|
@ -101,7 +103,7 @@ namespace BirdsiteLive.Domain.Tools
|
|||
|
||||
// Extract Mentions
|
||||
var mentionMatch = OrderByLength(_mentionRegex.Matches(messageContent));
|
||||
foreach (Match m in mentionMatch)
|
||||
foreach (Match m in mentionMatch.OrderByDescending(x => x.Length))
|
||||
{
|
||||
var mention = m.ToString().Replace("@", string.Empty).Replace("\n", string.Empty).Trim();
|
||||
var url = $"https://{_instanceSettings.Domain}/users/{mention}";
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<UserSecretsId>d21486de-a812-47eb-a419-05682bb68856</UserSecretsId>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<Version>0.6.0</Version>
|
||||
<Version>0.6.1</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -335,5 +335,22 @@ namespace BirdsiteLive.Domain.Tests.Tools
|
|||
Assert.IsTrue(result.content.Contains(@"😎 😍 🤗 🤩 😘"));
|
||||
#endregion
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Extract_Parenthesis_Test()
|
||||
{
|
||||
#region Stubs
|
||||
var message = $"bla (@mynickname test)";
|
||||
//var message = $"tests@mynickname";
|
||||
#endregion
|
||||
|
||||
var service = new StatusExtractor(_settings);
|
||||
var result = service.ExtractTags(message);
|
||||
|
||||
#region Validations
|
||||
Assert.AreEqual(1, result.tags.Length);
|
||||
Assert.IsTrue(result.content.Equals(@"bla ( <span class=""h-card""><a href=""https://domain.name/@mynickname"" class=""u-url mention"">@<span>mynickname</span></a></span> test)"));
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
Reference in a new issue