mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 13:47:05 +02:00
Open .ton as a tonsite.
This commit is contained in:
parent
a422aec99a
commit
148690d8b1
4 changed files with 18 additions and 5 deletions
|
@ -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<ClickHandlerContext>();
|
||||
if (!my.show) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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('/');
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 97bfa6cef474b3b311a178ff1a1042d09972a7c7
|
||||
Subproject commit 8db5d1aa533334c75ed2598ecf3607768ae9b418
|
Loading…
Add table
Reference in a new issue