From bbd401491b9287fbc24c3d374dbbb4591dd3ed2f Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 14 Jan 2020 07:26:35 +0300 Subject: [PATCH] Simplify check_url. GitOrigin-RevId: 5d00738d5eb8d7e18c9b462670e381720f1eda2c --- td/telegram/misc.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/td/telegram/misc.cpp b/td/telegram/misc.cpp index 35aa474e3..9405df4a8 100644 --- a/td/telegram/misc.cpp +++ b/td/telegram/misc.cpp @@ -281,19 +281,16 @@ string get_emoji_fingerprint(uint64 num) { Result check_url(Slice url) { bool is_tg = false; bool is_ton = false; - if (begins_with(url, "tg://")) { - url.remove_prefix(5); - is_tg = true; - } else if (begins_with(url, "tg:")) { + if (begins_with(url, "tg:")) { url.remove_prefix(3); is_tg = true; - } else if (begins_with(url, "ton://")) { - url.remove_prefix(6); - is_ton = true; } else if (begins_with(url, "ton:")) { url.remove_prefix(4); is_ton = true; } + if ((is_tg || is_ton) && begins_with(url, "//")) { + url.remove_prefix(2); + } TRY_RESULT(http_url, parse_url(url)); if (is_tg || is_ton) { if (begins_with(url, "http://") || http_url.protocol_ == HttpUrl::Protocol::HTTPS || !http_url.userinfo_.empty() ||