diff --git a/src/config.ts b/src/config.ts index 434b09e6c..71329341a 100644 --- a/src/config.ts +++ b/src/config.ts @@ -217,9 +217,9 @@ export const CONTENT_NOT_SUPPORTED = 'The message is not supported on this versi // eslint-disable-next-line max-len 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_TG_LINK = /^tg:(\/\/)?/; -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_TG_LINK = /^tg:(\/\/)?/i; +export const RE_TME_LINK = /^(https?:\/\/)?([-a-zA-Z0-9@:%_+~#=]{1,32}\.)?t\.me/i; +export const RE_TELEGRAM_LINK = /^(https?:\/\/)?telegram\.org\//i; export const TME_LINK_PREFIX = 'https://t.me/'; export const USERNAME_PURCHASE_ERROR = 'USERNAME_PURCHASE_AVAILABLE'; export const PURCHASE_USERNAME = 'auction'; diff --git a/src/global/actions/api/chats.ts b/src/global/actions/api/chats.ts index 7ed4b2818..896af0baf 100644 --- a/src/global/actions/api/chats.ts +++ b/src/global/actions/api/chats.ts @@ -868,7 +868,7 @@ addActionHandler('openTelegramLink', (global, actions, payload): ActionReturnTyp return; } - const uri = new URL(url.startsWith('http') ? url : `https://${url}`); + const uri = new URL(url.toLowerCase().startsWith('http') ? url : `https://${url}`); if (TME_WEB_DOMAINS.has(uri.hostname) && uri.pathname === '/') { window.open(uri.toString(), '_blank', 'noopener'); return;