URL: Fix opening /s/ links (#4750)

This commit is contained in:
zubiden 2024-07-15 15:51:57 +02:00 committed by Alexander Zinchuk
parent 890cee4366
commit 49ccbe3ee9
2 changed files with 8 additions and 2 deletions

View File

@ -1299,7 +1299,9 @@ addActionHandler('openTelegramLink', (global, actions, payload): ActionReturnTyp
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 adaptedPathname = uri.pathname.replace(/^\/?s\//, '');
const pathname = hostParts.length === 3 ? `${hostParts[0]}/${adaptedPathname}` : adaptedPathname;
const [part1, part2, part3] = pathname.split('/').filter(Boolean).map((part) => decodeURI(part));
const params = Object.fromEntries(uri.searchParams);

View File

@ -593,7 +593,11 @@ function isNumber(s: string) {
}
function getPathParams(url: URL) {
return url.pathname.split('/').filter(Boolean).map(decodeURI);
const parts = url.pathname.split('/').filter(Boolean);
if (parts[0] === 's') {
parts.shift();
}
return parts.map(decodeURI);
}
function getQueryParams(url: URL) {