Supports web client subdomains (#2305)
This commit is contained in:
parent
45027a4028
commit
bee376cdeb
@ -218,6 +218,7 @@ export const RE_TELEGRAM_LINK = /^(https?:\/\/)?telegram\.org\//;
|
||||
export const TME_LINK_PREFIX = 'https://t.me/';
|
||||
export const USERNAME_PURCHASE_ERROR = 'USERNAME_PURCHASE_AVAILABLE';
|
||||
export const PURCHASE_USERNAME = 'auction';
|
||||
export const TME_WEB_DOMAINS = new Set(['t.me', 'web.t.me', 'k.t.me', 'z.t.me']);
|
||||
|
||||
// eslint-disable-next-line max-len
|
||||
export const COUNTRIES_WITH_12H_TIME_FORMAT = new Set(['AU', 'BD', 'CA', 'CO', 'EG', 'HN', 'IE', 'IN', 'JO', 'MX', 'MY', 'NI', 'NZ', 'PH', 'PK', 'SA', 'SV', 'US']);
|
||||
|
||||
@ -17,7 +17,10 @@ import {
|
||||
SERVICE_NOTIFICATIONS_USER_ID,
|
||||
TMP_CHAT_ID,
|
||||
ALL_FOLDER_ID,
|
||||
DEBUG, TOPICS_SLICE, TOPICS_SLICE_SECOND_LOAD,
|
||||
DEBUG,
|
||||
TOPICS_SLICE,
|
||||
TOPICS_SLICE_SECOND_LOAD,
|
||||
TME_WEB_DOMAINS,
|
||||
} from '../../../config';
|
||||
import { callApi } from '../../../api/gramjs';
|
||||
import {
|
||||
@ -672,12 +675,13 @@ addActionHandler('openTelegramLink', (global, actions, payload) => {
|
||||
}
|
||||
|
||||
const uri = new URL(url.startsWith('http') ? url : `https://${url}`);
|
||||
if (uri.hostname === 't.me' && uri.pathname === '/') {
|
||||
if (TME_WEB_DOMAINS.has(uri.hostname) && uri.pathname === '/') {
|
||||
window.open(uri.toString(), '_blank', 'noopener');
|
||||
return;
|
||||
}
|
||||
|
||||
const hostParts = uri.hostname.split('.');
|
||||
const hostname = TME_WEB_DOMAINS.has(uri.hostname) ? 't.me' : uri.hostname;
|
||||
const hostParts = hostname.split('.');
|
||||
if (hostParts.length > 3) return;
|
||||
const pathname = hostParts.length === 3 ? `${hostParts[0]}/${uri.pathname}` : uri.pathname;
|
||||
const [part1, part2, part3] = pathname.split('/').filter(Boolean).map((part) => decodeURI(part));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user