diff --git a/apps/mobile/src/components/native/webview/native-webview.android.tsx b/apps/mobile/src/components/native/webview/native-webview.android.tsx index 7f0a48218..e6260dcc2 100644 --- a/apps/mobile/src/components/native/webview/native-webview.android.tsx +++ b/apps/mobile/src/components/native/webview/native-webview.android.tsx @@ -61,6 +61,13 @@ export const NativeWebView: React.ComponentType< allowsBackForwardNavigationGestures allowsFullscreenVideo injectedJavaScriptBeforeContentLoaded={atStart} + // setSupportMultipleWindows={false} + onOpenWindow={(e) => { + const { targetUrl } = e.nativeEvent + if (targetUrl) { + openLink(targetUrl) + } + }} onNavigationStateChange={onNavigationStateChange} onLoadEnd={onLoadEnd} onMessage={(e) => { @@ -99,7 +106,13 @@ const useWebViewNavigation = ({ webViewRef }: { webViewRef: RefObject { const { url: urlStr } = newNavState - const url = URL.canParse(urlStr) ? new URL(urlStr) : null + let url = null + try { + url = new URL(urlStr) + } catch (error) { + console.warn("Invalid URL", urlStr, error) + return + } if (!url) return if (url.protocol === "file:") return // if (allowHosts.has(url.host)) return