URL: Fix opening /s/ links (#4750)
This commit is contained in:
parent
890cee4366
commit
49ccbe3ee9
@ -1299,7 +1299,9 @@ addActionHandler('openTelegramLink', (global, actions, payload): ActionReturnTyp
|
|||||||
const hostname = TME_WEB_DOMAINS.has(uri.hostname) ? 't.me' : uri.hostname;
|
const hostname = TME_WEB_DOMAINS.has(uri.hostname) ? 't.me' : uri.hostname;
|
||||||
const hostParts = hostname.split('.');
|
const hostParts = hostname.split('.');
|
||||||
if (hostParts.length > 3) return;
|
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 [part1, part2, part3] = pathname.split('/').filter(Boolean).map((part) => decodeURI(part));
|
||||||
const params = Object.fromEntries(uri.searchParams);
|
const params = Object.fromEntries(uri.searchParams);
|
||||||
|
|
||||||
|
|||||||
@ -593,7 +593,11 @@ function isNumber(s: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getPathParams(url: URL) {
|
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) {
|
function getQueryParams(url: URL) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user