Only send source headers to the source in WebView

(cherry picked from commit a01867dc3e)
This commit is contained in:
AntsyLich
2026-10-26 02:44:25 +06:00
parent f43a0f5d9d
commit 4df6a4705b
@@ -32,6 +32,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.unit.dp
import androidx.core.net.toUri
import cafe.adriel.voyager.core.stack.mutableStateStackOf
import com.kevinnzou.web.AccompanistWebChromeClient
import com.kevinnzou.web.AccompanistWebViewClient
@@ -108,6 +109,8 @@ fun WebViewScreenContent(
onDispose { isActive = false }
}
val headersHost = remember { url.toUri().host }
val webClient = remember {
object : AccompanistWebViewClient() {
override fun onPageStarted(view: WebView, url: String?, favicon: Bitmap?) {
@@ -147,6 +150,9 @@ fun WebViewScreenContent(
// Ignore intents urls
if (url.startsWith("intent://")) return true
// Only send source headers to the source itself
if (request.url.host != headersHost) return false
// Only open valid web urls
if (url.startsWith("http") || url.startsWith("https")) {
if (url != view?.url) {