Skip to content

Commit

Permalink
prevent duplicate cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
Secozzi committed Oct 7, 2023
1 parent d1981a2 commit dde6aaa
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ class GDriveCookieJar : CookieJar {

// Append rather than overwrite, what could go wrong?
override fun saveFromResponse(url: HttpUrl, cookies: List<Cookie>) {
cookieStore[url.host] = ((cookieStore[url.host] ?: emptyList()) + cookies).toMutableList()
val oldCookies = (cookieStore[url.host] ?: emptyList()).filter { c ->
!cookies.any { t -> c.name == t.name }
}
cookieStore[url.host] = (oldCookies + cookies).toMutableList()
}

override fun loadForRequest(url: HttpUrl): List<Cookie> {
Expand Down

0 comments on commit dde6aaa

Please sign in to comment.