export function shouldOpenInMobileShellWebView( rawUrl: string, allowedOrigin: string, ) { if (rawUrl === 'about:blank') { return true; } if ( !rawUrl.startsWith('/') && !rawUrl.startsWith('#') && !/^[a-z][a-z0-9+.-]*:/i.test(rawUrl) ) { return false; } try { const url = new URL(rawUrl, allowedOrigin); if (url.protocol !== 'http:' && url.protocol !== 'https:') { return false; } return url.origin === allowedOrigin; } catch { return false; } }