Skip to content

Commit

Permalink
fix(preview-quote-toots): fix the regex, and also use stripped text
Browse files Browse the repository at this point in the history
I sometimes forget how things should work
  • Loading branch information
LucasGGamerM committed Jul 5, 2024
1 parent b670da0 commit 0788b03
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,10 @@ public static ArrayList<StatusDisplayItem> buildItems(BaseStatusListFragment<?>

// 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;
Expand Down

0 comments on commit 0788b03

Please sign in to comment.