diff --git a/src/BirdsiteLive.Domain/Tools/StatusExtractor.cs b/src/BirdsiteLive.Domain/Tools/StatusExtractor.cs index 7df4c0e..5cbff68 100644 --- a/src/BirdsiteLive.Domain/Tools/StatusExtractor.cs +++ b/src/BirdsiteLive.Domain/Tools/StatusExtractor.cs @@ -64,7 +64,7 @@ namespace BirdsiteLive.Domain.Tools secondPart = truncatedUrl.Substring(30); } - messageContent = Regex.Replace(messageContent, m.ToString(), + messageContent = Regex.Replace(messageContent, Regex.Escape(m.ToString()), $@"{m.Groups[1]}{protocol}{firstPart}{secondPart}"); } diff --git a/src/BirdsiteLive/BirdsiteLive.csproj b/src/BirdsiteLive/BirdsiteLive.csproj index 7c24384..26df777 100644 --- a/src/BirdsiteLive/BirdsiteLive.csproj +++ b/src/BirdsiteLive/BirdsiteLive.csproj @@ -4,7 +4,7 @@ netcoreapp3.1 d21486de-a812-47eb-a419-05682bb68856 Linux - 0.14.2 + 0.14.3 diff --git a/src/Tests/BirdsiteLive.Domain.Tests/Tools/StatusExtractorTests.cs b/src/Tests/BirdsiteLive.Domain.Tests/Tools/StatusExtractorTests.cs index 06d8f9a..a279dd0 100644 --- a/src/Tests/BirdsiteLive.Domain.Tests/Tools/StatusExtractorTests.cs +++ b/src/Tests/BirdsiteLive.Domain.Tests/Tools/StatusExtractorTests.cs @@ -217,6 +217,25 @@ namespace BirdsiteLive.Domain.Tests.Tools #endregion } + [TestMethod] + public void Extract_UrlRegexChars_Test() + { + #region Stubs + var message = @"🐣 juniors & tech(http://tech.guru maker)"; + #endregion + + #region Mocks + var logger = new Mock>(); + #endregion + + var service = new StatusExtractor(_settings, logger.Object); + var result = service.Extract(message); + + #region Validations + Assert.AreEqual(@"🐣 juniors & tech(http://tech.guru maker)", result.content); + #endregion + } + [TestMethod] public void Extract_SingleHashTag_Test() { @@ -345,7 +364,7 @@ namespace BirdsiteLive.Domain.Tests.Tools Assert.IsTrue(result.content.Contains(@"@mynickname")); #endregion } - + [TestMethod] public void Extract_SingleMentionTag_RT_Test() {