Better tg:// URL formatting.
GitOrigin-RevId: 766363c58886800c186bceabc8ce4746f1835bf6
This commit is contained in:
parent
1ef5c89a91
commit
1f9052f85b
@ -288,13 +288,17 @@ Result<string> check_url(MutableSlice url) {
|
||||
}
|
||||
TRY_RESULT(http_url, parse_url(url));
|
||||
if (is_tg) {
|
||||
if (begins_with(url, "http://") || http_url.protocol_ == HttpUrl::Protocol::HTTPS || !http_url.userinfo_.empty() || http_url.specified_port_ != 0 || http_url.is_ipv6_) {
|
||||
if (begins_with(url, "http://") || http_url.protocol_ == HttpUrl::Protocol::HTTPS || !http_url.userinfo_.empty() ||
|
||||
http_url.specified_port_ != 0 || http_url.is_ipv6_) {
|
||||
return Status::Error("Wrong tg URL");
|
||||
}
|
||||
|
||||
auto result = http_url.get_url();
|
||||
CHECK(begins_with(result, "http://"));
|
||||
return PSTRING() << "tg" << Slice(result).substr(4);
|
||||
Slice query(http_url.query_);
|
||||
CHECK(query[0] == '/');
|
||||
if (query[1] == '?') {
|
||||
query.remove_prefix(1);
|
||||
}
|
||||
return PSTRING() << "tg://" << http_url.host_ << query;
|
||||
}
|
||||
|
||||
if (url.find('.') == string::npos) {
|
||||
|
Loading…
Reference in New Issue
Block a user