Simplify match_url code.
This commit is contained in:
parent
0d2ddc2d56
commit
4206246b0c
@ -748,8 +748,6 @@ static vector<Slice> match_urls(Slice str) {
|
||||
|
||||
const unsigned char *last_at_ptr = nullptr;
|
||||
const unsigned char *domain_end_ptr = begin + dot_pos;
|
||||
if (domain_begin_ptr == begin || domain_begin_ptr[-1] != '@') {
|
||||
// try to find '@' to the right if there is no '@' to the left
|
||||
while (domain_end_ptr != end) {
|
||||
uint32 code = 0;
|
||||
auto next_ptr = next_utf8_unsafe(domain_end_ptr, &code);
|
||||
@ -760,15 +758,6 @@ static vector<Slice> match_urls(Slice str) {
|
||||
}
|
||||
domain_end_ptr = next_ptr;
|
||||
}
|
||||
}
|
||||
while (domain_end_ptr != end) {
|
||||
uint32 code = 0;
|
||||
auto next_ptr = next_utf8_unsafe(domain_end_ptr, &code);
|
||||
if (!is_domain_symbol(code)) {
|
||||
break;
|
||||
}
|
||||
domain_end_ptr = next_ptr;
|
||||
}
|
||||
|
||||
if (last_at_ptr != nullptr) {
|
||||
while (domain_begin_ptr != begin) {
|
||||
|
@ -704,6 +704,7 @@ TEST(MessageEntities, url) {
|
||||
check_url("http://test―‑@―google―.―com―/―–―‐―/―/―/―?―‑―#―――", {"http://test―‑@―google―.―com―/―–―‐―/―/―/―?―‑―#―――"});
|
||||
check_url("http://google.com/‖", {"http://google.com/"});
|
||||
check_url("a@b@c.com", {}, {});
|
||||
check_url("abc@c.com@d.com", {});
|
||||
check_url("a@b.com:c@1", {}, {"a@b.com"});
|
||||
check_url("test@test.software", {}, {"test@test.software"});
|
||||
check_url("a:b?@gmail.com", {});
|
||||
|
Loading…
Reference in New Issue
Block a user