Skip to content

Commit 4914a73

Browse files
committed
fix(wasmJs): warn when removeCookies(url) falls back to removing all cookies
Browser document.cookie API does not support URL-specific cookie removal. Log a warning instead of silently deleting all cookies.
1 parent dd2dae3 commit 4914a73

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

  • webview-compose/src/wasmJsMain/kotlin/io/github/kdroidfilter/webview/cookie

webview-compose/src/wasmJsMain/kotlin/io/github/kdroidfilter/webview/cookie/Cookie.wasmJs.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@file:OptIn(ExperimentalWasmJsInterop::class)
22
package io.github.kdroidfilter.webview.cookie
33

4+
import io.github.kdroidfilter.webview.util.KLogger
45
import kotlinx.browser.document
56

67
/**
@@ -62,11 +63,12 @@ object WasmJsCookieManager : CookieManager {
6263
}
6364

6465
override suspend fun removeCookies(url: String) {
65-
/**
66-
* In a browser context, we can't easily remove cookies for a specific URL,
67-
* So we'll use the same approach as removeAllCookies
68-
* Alternative: use CookieStore (https://developer.mozilla.org/en-US/docs/Web/API/CookieStore)
69-
*/
66+
// Browser document.cookie API does not support removing cookies for a specific URL/domain.
67+
// Falling back to removing all cookies. Consider using CookieStore API for finer control:
68+
// https://developer.mozilla.org/en-US/docs/Web/API/CookieStore
69+
KLogger.w(tag = "WasmJsCookieManager") {
70+
"removeCookies(url=$url): URL-specific cookie removal is not supported in browser context, removing all cookies instead"
71+
}
7072
removeAllCookies()
7173
}
7274
}

0 commit comments

Comments
 (0)