Support t.me subdomains (#2023)
This commit is contained in:
parent
50dc91d71d
commit
1a89181e1d
@ -8,6 +8,7 @@ import { getActions, withGlobal } from '../../../global';
|
|||||||
import { ApiMediaFormat } from '../../../api/types';
|
import { ApiMediaFormat } from '../../../api/types';
|
||||||
import { ProfileEditProgress } from '../../../types';
|
import { ProfileEditProgress } from '../../../types';
|
||||||
|
|
||||||
|
import { TME_LINK_PREFIX } from '../../../config';
|
||||||
import { throttle } from '../../../util/schedulers';
|
import { throttle } from '../../../util/schedulers';
|
||||||
import { selectUser } from '../../../global/selectors';
|
import { selectUser } from '../../../global/selectors';
|
||||||
import { getChatAvatarHash } from '../../../global/helpers';
|
import { getChatAvatarHash } from '../../../global/helpers';
|
||||||
@ -228,7 +229,7 @@ const SettingsEditProfile: FC<OwnProps & StateProps> = ({
|
|||||||
{username && (
|
{username && (
|
||||||
<p className="settings-item-description" dir={lang.isRtl ? 'rtl' : undefined}>
|
<p className="settings-item-description" dir={lang.isRtl ? 'rtl' : undefined}>
|
||||||
{lang('lng_username_link')}<br />
|
{lang('lng_username_link')}<br />
|
||||||
<span className="username-link">https://t.me/{username}</span>
|
<span className="username-link">{TME_LINK_PREFIX}{username}</span>
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import { getActions, withGlobal } from '../../../global';
|
|||||||
import type { ApiChat, ApiExportedInvite } from '../../../api/types';
|
import type { ApiChat, ApiExportedInvite } from '../../../api/types';
|
||||||
import { ManagementScreens } from '../../../types';
|
import { ManagementScreens } from '../../../types';
|
||||||
|
|
||||||
import { STICKER_SIZE_INVITES } from '../../../config';
|
import { STICKER_SIZE_INVITES, TME_LINK_PREFIX } from '../../../config';
|
||||||
import { LOCAL_TGS_URLS } from '../../common/helpers/animatedAssets';
|
import { LOCAL_TGS_URLS } from '../../common/helpers/animatedAssets';
|
||||||
import useHistoryBack from '../../../hooks/useHistoryBack';
|
import useHistoryBack from '../../../hooks/useHistoryBack';
|
||||||
import useLang from '../../../hooks/useLang';
|
import useLang from '../../../hooks/useLang';
|
||||||
@ -100,7 +100,7 @@ const ManageInvites: FC<OwnProps & StateProps> = ({
|
|||||||
}, hasDetailedCountdown ? 1000 : undefined);
|
}, hasDetailedCountdown ? 1000 : undefined);
|
||||||
|
|
||||||
const primaryInvite = exportedInvites?.find(({ isPermanent }) => isPermanent);
|
const primaryInvite = exportedInvites?.find(({ isPermanent }) => isPermanent);
|
||||||
const primaryInviteLink = chat?.username ? `t.me/${chat.username}` : primaryInvite?.link;
|
const primaryInviteLink = chat?.username ? `${TME_LINK_PREFIX}${chat.username}` : primaryInvite?.link;
|
||||||
const temporalInvites = useMemo(() => {
|
const temporalInvites = useMemo(() => {
|
||||||
const invites = chat?.username ? exportedInvites : exportedInvites?.filter(({ isPermanent }) => !isPermanent);
|
const invites = chat?.username ? exportedInvites : exportedInvites?.filter(({ isPermanent }) => !isPermanent);
|
||||||
return invites?.sort(inviteComparator);
|
return invites?.sort(inviteComparator);
|
||||||
|
|||||||
@ -194,7 +194,7 @@ export const CONTENT_NOT_SUPPORTED = 'The message is not supported on this versi
|
|||||||
export const RE_LINK_TEMPLATE = '((ftp|https?):\\/\\/)?((www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,63})\\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)';
|
export const RE_LINK_TEMPLATE = '((ftp|https?):\\/\\/)?((www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,63})\\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)';
|
||||||
export const RE_MENTION_TEMPLATE = '(@[\\w\\d_-]+)';
|
export const RE_MENTION_TEMPLATE = '(@[\\w\\d_-]+)';
|
||||||
export const RE_TG_LINK = /^tg:(\/\/)?([?=&\d\w_-]+)?/;
|
export const RE_TG_LINK = /^tg:(\/\/)?([?=&\d\w_-]+)?/;
|
||||||
export const RE_TME_LINK = /^(https?:\/\/)?t\.me\//;
|
export const RE_TME_LINK = /^(https?:\/\/)?([-a-zA-Z0-9@:%_+~#=]{1,32}\.)?t\.me/;
|
||||||
export const RE_TELEGRAM_LINK = /^(https?:\/\/)?telegram\.org\//;
|
export const RE_TELEGRAM_LINK = /^(https?:\/\/)?telegram\.org\//;
|
||||||
export const TME_LINK_PREFIX = 'https://t.me/';
|
export const TME_LINK_PREFIX = 'https://t.me/';
|
||||||
|
|
||||||
|
|||||||
@ -586,7 +586,15 @@ addActionHandler('openTelegramLink', (global, actions, payload) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const uri = new URL(url.startsWith('http') ? url : `https://${url}`);
|
const uri = new URL(url.startsWith('http') ? url : `https://${url}`);
|
||||||
const [part1, part2, part3] = uri.pathname.split('/').filter(Boolean).map((l) => decodeURI(l));
|
if (uri.hostname === 't.me' && uri.pathname === '/') {
|
||||||
|
window.open(uri.toString(), '_blank', 'noopener');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const hostParts = uri.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((l) => decodeURI(l));
|
||||||
const params = Object.fromEntries(uri.searchParams);
|
const params = Object.fromEntries(uri.searchParams);
|
||||||
|
|
||||||
let hash: string | undefined;
|
let hash: string | undefined;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user