From 010b5e39491c2adeaff53f6de9374ae44cbd2f51 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 31 Aug 2022 19:44:57 +0400 Subject: [PATCH] Support username.t.me links. --- Telegram/SourceFiles/core/local_url_handlers.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index c1b5947d78..4c99051956 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -876,6 +876,13 @@ QString TryConvertUrlToLocal(QString url) { using namespace qthelp; auto matchOptions = RegExOption::CaseInsensitive; + auto subdomainMatch = regex_match(qsl("^(https?://)?([a-zA-Z0-9\\_]+)\\.t\\.me/?(\\?.+)?"), url, matchOptions); + if (subdomainMatch) { + const auto name = subdomainMatch->captured(2); + if (name.size() > 1 && name != "www") { + url = subdomainMatch->captured(1) + "t.me/" + name + subdomainMatch->captured(3); + } + } auto telegramMeMatch = regex_match(qsl("^(https?://)?(www\\.)?(telegram\\.(me|dog)|t\\.me)/(.+)$"), url, matchOptions); if (telegramMeMatch) { auto query = telegramMeMatch->capturedView(5);