Support mailto emails.

GitOrigin-RevId: aca706aee9b1adb34f3f25700e91cd0d0880424f
This commit is contained in:
levlam 2018-06-25 03:15:38 +03:00
parent 28ddc0525c
commit a365284831
2 changed files with 3 additions and 0 deletions

View File

@ -1011,6 +1011,8 @@ vector<std::pair<Slice, bool>> find_urls(Slice str) {
for (auto url : match_urls(str)) {
if (is_email_address(url)) {
result.emplace_back(url, true);
} else if (begins_with(url, "mailto:") && is_email_address(url.substr(7))) {
result.emplace_back(url.substr(7), true);
} else {
url = fix_url(url);
if (!url.empty()) {

View File

@ -515,6 +515,7 @@ TEST(MessageEntities, url) {
check_url("<http://www.ics.uci.edu/pub/ietf/uri/historical.html#WARNING>",
{"http://www.ics.uci.edu/pub/ietf/uri/historical.html#WARNING"});
check_url("Look :test@example.com", {":test@example.com"}, {}); // TODO {}, {"test@example.com"}
check_url("Look mailto:test@example.com", {}, {"test@example.com"});
check_url("http://test.com#a", {"http://test.com#a"});
check_url("http://test.com#", {"http://test.com#"});
check_url("http://test.com?#", {"http://test.com?#"});