Deeplink: Fix tg:// links on Chrome <130 (#5444)
This commit is contained in:
parent
d4864f93d3
commit
9b57bd9e21
@ -4,6 +4,7 @@ import { RE_TG_LINK, RE_TME_LINK } from '../config';
|
||||
import { toChannelId } from '../global/helpers';
|
||||
import { ensureProtocol } from './ensureProtocol';
|
||||
import { isUsernameValid } from './username';
|
||||
import { IS_BAD_URL_PARSER } from './windowEnvironment';
|
||||
|
||||
export type DeepLinkMethod = 'resolve' | 'login' | 'passport' | 'settings' | 'join' | 'addstickers' | 'addemoji' |
|
||||
'setlanguage' | 'addtheme' | 'confirmphone' | 'socks' | 'proxy' | 'privatepost' | 'bg' | 'share' | 'msg' | 'msg_url' |
|
||||
@ -148,8 +149,8 @@ function parseDeepLink(url: string) {
|
||||
return parseHttpLink(urlParsed);
|
||||
}
|
||||
if (correctUrl.startsWith('tg:')) {
|
||||
// Chrome parse url with tg: protocol incorrectly
|
||||
const urlParsed = new URL(correctUrl.replace(/^tg:/, 'http:'));
|
||||
const urlToParse = IS_BAD_URL_PARSER ? correctUrl.replace(/^tg:\/\//, 'https://') : correctUrl;
|
||||
const urlParsed = new URL(urlToParse);
|
||||
return parseTgLink(urlParsed);
|
||||
}
|
||||
return undefined;
|
||||
|
||||
@ -6,6 +6,7 @@ import type { DeepLinkMethod, PrivateMessageLink } from './deepLinkParser';
|
||||
import { API_CHAT_TYPES, RE_TG_LINK } from '../config';
|
||||
import { toChannelId } from '../global/helpers';
|
||||
import { tryParseDeepLink } from './deepLinkParser';
|
||||
import { IS_BAD_URL_PARSER } from './windowEnvironment';
|
||||
|
||||
export const processDeepLink = (url: string): boolean => {
|
||||
const actions = getActions();
|
||||
@ -74,9 +75,11 @@ export const processDeepLink = (url: string): boolean => {
|
||||
return false;
|
||||
}
|
||||
|
||||
const urlToParse = IS_BAD_URL_PARSER ? url.replace(/^tg:\/\//, 'https://') : url;
|
||||
|
||||
const {
|
||||
protocol, searchParams, hostname,
|
||||
} = new URL(url);
|
||||
} = new URL(urlToParse);
|
||||
|
||||
if (protocol !== 'tg:') return false;
|
||||
|
||||
|
||||
@ -108,6 +108,8 @@ export const IS_OPEN_IN_NEW_TAB_SUPPORTED = IS_MULTITAB_SUPPORTED && !(IS_PWA &&
|
||||
export const IS_TRANSLATION_SUPPORTED = !IS_TEST;
|
||||
export const IS_INTL_LIST_FORMAT_SUPPORTED = 'ListFormat' in Intl;
|
||||
|
||||
export const IS_BAD_URL_PARSER = new URL('tg://host').host !== 'host';
|
||||
|
||||
export const MESSAGE_LIST_SENSITIVE_AREA = 750;
|
||||
|
||||
export const SCROLLBAR_WIDTH = (() => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user