From e9da1a80b711a278d4567bb14f9ebdea37a41338 Mon Sep 17 00:00:00 2001 From: Zoe Martin Date: Fri, 25 Jun 2021 15:05:25 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20issues=20with=20urls=20being=20cut=20in?= =?UTF-8?q?=20half=20at=20the=20end=20of=20replies=20and=20"=E2=80=A6"=20u?= =?UTF-8?q?nnecessarily=20being=20appended=20at=20the=20end?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PluralKit.Bot/Proxy/ProxyService.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/PluralKit.Bot/Proxy/ProxyService.cs b/PluralKit.Bot/Proxy/ProxyService.cs index 97df8667..a70322aa 100644 --- a/PluralKit.Bot/Proxy/ProxyService.cs +++ b/PluralKit.Bot/Proxy/ProxyService.cs @@ -184,12 +184,21 @@ namespace PluralKit.Bot if (repliedTo.Content.Contains(msg + mentionTail + ">")) msg += mentionTail + ">"; } + + var endsWithUrl = Regex.IsMatch(msg, + @"(http|https)?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$"); + if (endsWithUrl) + { + var urlTail = repliedTo.Content.Substring(100).Split(" ")[0]; + msg += urlTail + " "; + } var spoilersInOriginalString = Regex.Matches(repliedTo.Content, @"\|\|").Count; var spoilersInTruncatedString = Regex.Matches(msg, @"\|\|").Count; if (spoilersInTruncatedString % 2 == 1 && spoilersInOriginalString % 2 == 0) msg += "||"; - msg += "…"; + if (msg != repliedTo.Content) + msg += "…"; } content.Append($"**[Reply to:]({jumpLink})** ");