Fix WebView crash introduced in v0.19.2 (#2649)

This commit is contained in:
bapeey
2025-11-04 00:43:40 -05:00
committed by GitHub
parent e8bdf58530
commit bdb0ce4779
2 changed files with 12 additions and 11 deletions

View File

@@ -11,6 +11,8 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
- `Other` - for technical stuff.
## [Unreleased]
### Fixed
- Fix WebView crash introduced in 0.19.2 ([@bapeey](https://github.com/bapeey)) ([#2649](https://github.com/mihonapp/mihon/pull/2649))
## [v0.19.2] - 2025-11-02
### Added

View File

@@ -133,21 +133,20 @@ fun WebViewScreenContent(
view: WebView?,
request: WebResourceRequest?,
): Boolean {
request?.let {
// Don't attempt to open blobs as webpages
if (it.url.toString().startsWith("blob:http")) {
return false
}
val url = request?.url?.toString() ?: return false
// Ignore intents urls
if (it.url.toString().startsWith("intent://")) {
// Ignore intents urls
if (url.startsWith("intent://")) return true
// Only open valid web urls
if (url.startsWith("http") || url.startsWith("https")) {
if (url != view?.url) {
view?.loadUrl(url, headers)
return true
}
// Continue with request, but with custom headers
view?.loadUrl(it.url.toString(), headers)
}
return super.shouldOverrideUrlLoading(view, request)
return false
}
}
}