diff --git a/Telegram/SourceFiles/core/click_handler_types.cpp b/Telegram/SourceFiles/core/click_handler_types.cpp index 915b12f4f..b1ba3d166 100644 --- a/Telegram/SourceFiles/core/click_handler_types.cpp +++ b/Telegram/SourceFiles/core/click_handler_types.cpp @@ -122,7 +122,9 @@ void HiddenUrlClickHandler::Open(QString url, QVariant context) { return result; }())); } else { - const auto parsedUrl = QUrl::fromUserInput(url); + const auto parsedUrl = url.startsWith(u"tonsite://"_q) + ? QUrl(url) + : QUrl::fromUserInput(url); if (UrlRequiresConfirmation(parsedUrl) && !base::IsCtrlPressed()) { const auto my = context.value(); if (!my.show) { diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index 6777464c1..28aa99822 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -1337,6 +1337,13 @@ QString TryConvertUrlToLocal(QString url) { using namespace qthelp; auto matchOptions = RegExOption::CaseInsensitive; + auto tonsiteMatch = (url.indexOf(u".ton") >= 0) + ? regex_match(u"^(https?://)?[^/@:]+\\.ton($|/)"_q, url, matchOptions) + : RegularExpressionMatch(QRegularExpressionMatch()); + if (tonsiteMatch) { + const auto protocol = tonsiteMatch->captured(1); + return u"tonsite://"_q + url.mid(protocol.size()); + } auto subdomainMatch = regex_match(u"^(https?://)?([a-zA-Z0-9\\_]+)\\.t\\.me(/\\d+)?/?(\\?.+)?"_q, url, matchOptions); if (subdomainMatch) { const auto name = subdomainMatch->captured(2); diff --git a/Telegram/SourceFiles/iv/iv_controller.cpp b/Telegram/SourceFiles/iv/iv_controller.cpp index e369ab5c0..067e90b48 100644 --- a/Telegram/SourceFiles/iv/iv_controller.cpp +++ b/Telegram/SourceFiles/iv/iv_controller.cpp @@ -166,12 +166,16 @@ namespace { }; auto parsed = QUrl(value); if (parsed.isValid()) { + const auto host = ChangeHost(parsed.host()); + const auto emptyPath = parsed.path().isEmpty(); parsed.setScheme("tonsite"); - parsed.setHost(ChangeHost(parsed.host())); - if (parsed.path().isEmpty()) { + parsed.setHost(host); + if (emptyPath) { parsed.setPath(u"/"_q); } - return parsed.toString(); + if (parsed.isValid()) { + return parsed.toString(); + } } const auto part = value.mid(u"https://"_q.size()); const auto split = part.indexOf('/'); diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 97bfa6cef..8db5d1aa5 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 97bfa6cef474b3b311a178ff1a1042d09972a7c7 +Subproject commit 8db5d1aa533334c75ed2598ecf3607768ae9b418