Skip to content

Commit

Permalink
Merge branch 'termux:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
weigui404 authored Nov 10, 2024
2 parents eb1c9e7 + fb01127 commit c92faba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public class FileReceiverActivity extends AppCompatActivity {
private static final String LOG_TAG = "FileReceiverActivity";

static boolean isSharedTextAnUrl(String sharedText) {
if (sharedText == null || sharedText.isEmpty()) return false;

return Patterns.WEB_URL.matcher(sharedText).matches()
|| Pattern.matches("magnet:\\?xt=urn:btih:.*?", sharedText);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public void testIsSharedTextAnUrl() {

List<String> invalidUrls = new ArrayList<>();
invalidUrls.add("a test with example.com");
invalidUrls.add("");
invalidUrls.add(null);
for (String url : invalidUrls) {
Assert.assertFalse(FileReceiverActivity.isSharedTextAnUrl(url));
}
Expand Down

0 comments on commit c92faba

Please sign in to comment.