From 0788b03828a661676cee9f2d7bd472bb633cceac Mon Sep 17 00:00:00 2001 From: LucasGGamerM Date: Fri, 5 Jul 2024 19:28:41 -0300 Subject: [PATCH] fix(preview-quote-toots): fix the regex, and also use stripped text I sometimes forget how things should work --- .../android/ui/displayitems/StatusDisplayItem.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java index e281331b2..0607ede1f 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java @@ -380,10 +380,10 @@ public abstract class StatusDisplayItem{ // I actually forgot where I took this, but it works Pattern pattern = Pattern.compile("[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)"); - Matcher matcher = pattern.matcher(statusForContent.content); + Matcher matcher = pattern.matcher(statusForContent.getStrippedText()); String lastUrl = null; - if (matcher.find()) { + while (matcher.find()) { lastUrl = matcher.group(0); // The regex doesn't capture the scheme, so I add one here manually, so that the looksLikeFediverseUrlMethod actually works lastUrl = "https://" + lastUrl;