From 18bc812cf176d5c98335c6c6a5e8f3107356ff47 Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 27 Jul 2022 15:54:24 +0200 Subject: [PATCH] Fix issue #276 - Search OG when there is only one URL --- .../main/java/app/fedilab/android/BaseMainActivity.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/BaseMainActivity.java index 031278383..238f616c7 100644 --- a/app/src/main/java/app/fedilab/android/BaseMainActivity.java +++ b/app/src/main/java/app/fedilab/android/BaseMainActivity.java @@ -302,13 +302,16 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt */ Matcher matcher; matcher = Patterns.WEB_URL.matcher(sharedText); + int count = 0; while (matcher.find()) { int matchStart = matcher.start(1); int matchEnd = matcher.end(); - if (matchStart < matchEnd && sharedText.length() >= matchEnd) + if (matchStart < matchEnd && sharedText.length() >= matchEnd) { url[0] = sharedText.substring(matchStart, matchEnd); + count++; + } } - if (url[0] != null && url[0].length() == sharedText.length()) { + if (url[0] != null && count == 1) { new Thread(() -> { if (url[0].startsWith("www.")) url[0] = "http://" + url[0];