chore: fix broken telegram links
CI / changes (pull_request) Successful in 3s
CI / unit (pull_request) Successful in 11s
CI / integration (pull_request) Successful in 21s
CI / ui (pull_request) Successful in 1m14s
CI / conformance (pull_request) Successful in 10s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 2m7s

This commit is contained in:
Ilia Denisov
2026-07-14 09:06:03 +02:00
parent c522e77599
commit 564abdcf88
24 changed files with 50 additions and 50 deletions
+1 -1
View File
@@ -134,7 +134,7 @@
<span class="sep" aria-hidden="true">|</span>
<!-- The feedback bot: the Telegram contact the legal documents list as the seller's contact;
external, opens in a new tab. -->
<a class="doc" href="https://t.me/Erudit_GameBot" target="_blank" rel="noopener noreferrer">{t('landing.feedback')}</a>
<a class="doc" href="https://telegram.me/Erudit_GameBot" target="_blank" rel="noopener noreferrer">{t('landing.feedback')}</a>
</span>
<span>{t('about.version', { v: __APP_VERSION__ })}</span>
</footer>
+1 -1
View File
@@ -15,7 +15,7 @@
function openBot() {
if (username) {
const url = `https://t.me/${username}`;
const url = `https://telegram.me/${username}`;
// Inside Telegram, openTelegramLink navigates to the bot chat natively; elsewhere fall
// back to a new tab (routed out of the Android VK WebView by openExternalUrl).
if (!telegramOpenLink(url)) openExternalUrl(url);
+1 -1
View File
@@ -18,7 +18,7 @@
function openBot() {
if (username) {
const url = `https://t.me/${username}`;
const url = `https://telegram.me/${username}`;
// Inside Telegram, openTelegramLink navigates to the bot chat natively; elsewhere fall
// back to a new tab (routed out of the Android VK WebView by openExternalUrl).
if (!telegramOpenLink(url)) openExternalUrl(url);
+3 -3
View File
@@ -32,8 +32,8 @@ describe('shareLink', () => {
});
it('wraps a payload in a startapp link', () => {
vi.stubEnv('VITE_TELEGRAM_LINK', 'https://t.me/bot/app');
expect(shareLink('f123456')).toBe('https://t.me/bot/app?startapp=f123456');
vi.stubEnv('VITE_TELEGRAM_LINK', 'https://telegram.me/bot/app');
expect(shareLink('f123456')).toBe('https://telegram.me/bot/app?startapp=f123456');
});
});
@@ -60,7 +60,7 @@ describe('botUsername', () => {
});
it('extracts the bot handle from the Mini App link', () => {
vi.stubEnv('VITE_TELEGRAM_LINK', 'https://t.me/bot/app');
vi.stubEnv('VITE_TELEGRAM_LINK', 'https://telegram.me/bot/app');
expect(botUsername()).toBe('bot');
});
});
+2 -2
View File
@@ -43,7 +43,7 @@ function envVar(name: string): string | undefined {
}
/**
* telegramBase returns the single bot's Mini App link base (e.g. https://t.me/<bot>/<app>)
* telegramBase returns the single bot's Mini App link base (e.g. https://telegram.me/<bot>/<app>)
* from VITE_TELEGRAM_LINK, or null when it is not configured.
*/
function telegramBase(): string | null {
@@ -52,7 +52,7 @@ function telegramBase(): string | null {
/**
* botUsername extracts the bot's @username (without the @) from the configured Mini App
* link: the first path segment of https://t.me/<bot>/<app>. Returns null when no base is
* link: the first path segment of https://telegram.me/<bot>/<app>. Returns null when no base is
* configured or the link carries no path.
*/
export function botUsername(): string | null {
+1 -1
View File
@@ -6,7 +6,7 @@ describe('telegramChannelLink', () => {
it('builds the t.me link from the channel name', () => {
vi.stubEnv('VITE_TELEGRAM_GAME_CHANNEL_NAME', '@Erudit_Game'); // a leading @ is tolerated
expect(telegramChannelLink()).toBe('https://t.me/Erudit_Game');
expect(telegramChannelLink()).toBe('https://telegram.me/Erudit_Game');
});
it('returns null when the channel name is unset or blank', () => {
+1 -1
View File
@@ -11,7 +11,7 @@
export function telegramChannelLink(): string | null {
const raw = import.meta.env.VITE_TELEGRAM_GAME_CHANNEL_NAME;
const name = (raw as string | undefined)?.trim().replace(/^@/, '');
return name ? `https://t.me/${name}` : null;
return name ? `https://telegram.me/${name}` : null;
}
/**
+4 -4
View File
@@ -13,9 +13,9 @@ describe('openExternalUrl', () => {
origin: 'https://app.example',
});
vi.stubGlobal('window', { open });
openExternalUrl('https://t.me/some_bot');
openExternalUrl('https://telegram.me/some_bot');
expect(open).toHaveBeenCalledWith(
`https://vk.com/away.php?to=${encodeURIComponent('https://t.me/some_bot')}`,
`https://vk.com/away.php?to=${encodeURIComponent('https://telegram.me/some_bot')}`,
'_blank',
);
});
@@ -23,7 +23,7 @@ describe('openExternalUrl', () => {
it('opens a plain new tab elsewhere', () => {
const open = vi.fn();
vi.stubGlobal('window', { open });
openExternalUrl('https://t.me/some_bot');
expect(open).toHaveBeenCalledWith('https://t.me/some_bot', '_blank');
openExternalUrl('https://telegram.me/some_bot');
expect(open).toHaveBeenCalledWith('https://telegram.me/some_bot', '_blank');
});
});
+1 -1
View File
@@ -148,7 +148,7 @@ describe('routeExternalLinkInTelegram', () => {
it('leaves a t.me link to the native handler (openTelegramLink owns those)', () => {
const openLink = stubInside();
expect(routeExternalLinkInTelegram({ href: 'https://t.me/some_bot', target: '_blank' })).toBe(false);
expect(routeExternalLinkInTelegram({ href: 'https://telegram.me/some_bot', target: '_blank' })).toBe(false);
expect(openLink).not.toHaveBeenCalled();
});
+3 -3
View File
@@ -226,19 +226,19 @@ export function isExternalHttpUrl(href: string): boolean {
export function routeExternalLinkInTelegram(anchor: { href: string; target: string }): boolean {
if (!insideTelegram()) return false;
if (anchor.target !== '_blank') return false;
if (anchor.href.startsWith('https://t.me/')) return false;
if (anchor.href.startsWith('https://telegram.me/')) return false;
if (!isExternalHttpUrl(anchor.href)) return false;
return telegramOpenExternalLink(anchor.href);
}
/**
* shareTelegramLink opens Telegram's native "share to a chat" picker for url with a
* caption, through the Mini App SDK (https://t.me/share/url). Returns false outside
* caption, through the Mini App SDK (https://telegram.me/share/url). Returns false outside
* Telegram or when the SDK lacks the method, so the caller can fall back to the Web
* Share API. Works consistently on iOS and Android within Telegram.
*/
export function shareTelegramLink(url: string, text: string): boolean {
return telegramOpenLink(`https://t.me/share/url?url=${encodeURIComponent(url)}&text=${encodeURIComponent(text)}`);
return telegramOpenLink(`https://telegram.me/share/url?url=${encodeURIComponent(url)}&text=${encodeURIComponent(text)}`);
}
/** TelegramLaunch is the data a Mini App launch carries. */