fix(ui): route external links out of the Android VK WebView
The Android VK client's WebView ignores target=_blank and navigates the Mini App's own window to the target, stranding the player outside the game with no way back (the dictionary lookup, About/Feedback links, the ad banner and the bot-link modal fallbacks). vk-bridge 3.x has no method to open an external URL, so external links are routed through VK's own leave-VK redirect (vk.com/away.php), which the client intercepts natively and hands to the system browser. onExternalLinkClick moves from lib/telegram to a new lib/links that composes the Telegram and VK routers; iOS and desktop VK open _blank correctly and are left alone.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { openExternalUrl } from './links';
|
||||
|
||||
describe('openExternalUrl', () => {
|
||||
afterEach(() => vi.unstubAllGlobals());
|
||||
|
||||
it('routes through the VK away redirect inside the Android VK client', () => {
|
||||
const open = vi.fn();
|
||||
vi.stubGlobal('location', {
|
||||
pathname: '/vk/',
|
||||
search: '?vk_user_id=1&vk_platform=mobile_android&sign=x',
|
||||
href: 'https://app.example/vk/',
|
||||
origin: 'https://app.example',
|
||||
});
|
||||
vi.stubGlobal('window', { open });
|
||||
openExternalUrl('https://t.me/some_bot');
|
||||
expect(open).toHaveBeenCalledWith(
|
||||
`https://vk.com/away.php?to=${encodeURIComponent('https://t.me/some_bot')}`,
|
||||
'_blank',
|
||||
);
|
||||
});
|
||||
|
||||
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');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user