这是indexloc提供的服务,不要输入任何密码
Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 35 additions & 4 deletions app/src/test/java/com/termux/app/TermuxActivityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,46 @@ private void assertUrlsAre(String text, String... urls) {

@Test
public void testExtractUrls() {
// Basic single URL
assertUrlsAre("hello http://example.com world", "http://example.com");

assertUrlsAre("http://example.com\nhttp://another.com", "http://example.com", "http://another.com");
// Multiple URLs separated by newlines
assertUrlsAre("http://example.com\nhttp://another.com",
"http://example.com", "http://another.com");

assertUrlsAre("hello http://example.com world and http://more.example.com with secure https://more.example.com",
"http://example.com", "http://more.example.com", "https://more.example.com");
// Multiple mixed protocols
assertUrlsAre("hello http://example.com and https://secure.com",
"http://example.com", "https://secure.com");

assertUrlsAre("hello https://example.com/#bar https://example.com/foo#bar",
// URLs with fragments
assertUrlsAre("https://example.com/#bar https://example.com/foo#bar",
"https://example.com/#bar", "https://example.com/foo#bar");

// FTP and mailto links
assertUrlsAre("Check ftp://server.com/file.txt and mailto:user@example.com",
"ftp://server.com/file.txt", "mailto:user@example.com");

// Encoded characters in URL
assertUrlsAre("Search: https://example.com/search?q=test%20query",
"https://example.com/search?q=test%20query");

// URL starting with www (if supported)
assertUrlsAre("Visit www.example.com for info", "www.example.com");

// URL inside parentheses
assertUrlsAre("Click (http://example.com)", "http://example.com");

// URL inside quotes
assertUrlsAre("\"https://secure.example.com\"", "https://secure.example.com");

// Plain text without links
assertUrlsAre("This is a plain text with no links at all");

// Duplicate URLs
assertUrlsAre("http://example.com and again http://example.com", "http://example.com");

// Internationalized domain name
assertUrlsAre("Check this: https://مثال.إختبار", "https://مثال.إختبار");
}

}