diff --git a/.changes/currentUrl.md b/.changes/currentUrl.md new file mode 100644 index 000000000..13557bc99 --- /dev/null +++ b/.changes/currentUrl.md @@ -0,0 +1,5 @@ +--- +"wry": patch +--- + +On Android, set `RustWebViewClient.currentUrl` field early in `onPageStarted` method instead of `onPageFinished` diff --git a/src/android/kotlin/RustWebViewClient.kt b/src/android/kotlin/RustWebViewClient.kt index 2dae181d9..3b69dcab7 100644 --- a/src/android/kotlin/RustWebViewClient.kt +++ b/src/android/kotlin/RustWebViewClient.kt @@ -39,6 +39,7 @@ class RustWebViewClient(context: Context): WebViewClient() { } override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) { + currentUrl = url if (interceptedState[url] == false) { val webView = view as RustWebView for (script in webView.initScripts) { @@ -49,7 +50,6 @@ class RustWebViewClient(context: Context): WebViewClient() { } override fun onPageFinished(view: WebView, url: String) { - currentUrl = url return onPageLoaded(url) }