From 854474f85ffc41eccdc2b3a6cf105fa2805ebc3c Mon Sep 17 00:00:00 2001 From: FooIbar <118464521+FooIbar@users.noreply.github.com> Date: Tue, 6 Aug 2024 22:39:49 +0800 Subject: [PATCH] Don't crash on ill-formed URLs (#1084) --- .../eu/kanade/tachiyomi/ui/webview/WebViewScreenModel.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewScreenModel.kt index 331d62b59..833806db8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewScreenModel.kt @@ -10,7 +10,7 @@ import eu.kanade.tachiyomi.util.system.openInBrowser import eu.kanade.tachiyomi.util.system.toShareIntent import eu.kanade.tachiyomi.util.system.toast import logcat.LogPriority -import okhttp3.HttpUrl.Companion.toHttpUrl +import okhttp3.HttpUrl.Companion.toHttpUrlOrNull import tachiyomi.core.common.util.system.logcat import tachiyomi.domain.source.service.SourceManager import uy.kohesive.injekt.Injekt @@ -47,7 +47,9 @@ class WebViewScreenModel( } fun clearCookies(url: String) { - val cleared = network.cookieJar.remove(url.toHttpUrl()) - logcat { "Cleared $cleared cookies for: $url" } + url.toHttpUrlOrNull()?.let { + val cleared = network.cookieJar.remove(it) + logcat { "Cleared $cleared cookies for: $url" } + } } }