Skip to content

Commit 67ae972

Browse files
committed
Fixed cookies for wasmJs
1 parent 3b32aa6 commit 67ae972

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

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

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ data class Cookie(
2121
STRICT,
2222
}
2323

24-
override fun toString(): String {
25-
var cookieValue = "$name=$value"
26-
27-
if (path != null) cookieValue += "; Path=$path"
28-
if (domain != null) cookieValue += "; Domain=$domain"
29-
if (expiresDate != null) cookieValue += "; Expires=" + getCookieExpirationDate(expiresDate)
30-
if (maxAge != null) cookieValue += "; Max-Age=$maxAge"
31-
if (isSecure == true) cookieValue += "; Secure"
32-
if (isHttpOnly == true) cookieValue += "; HttpOnly"
33-
if (sameSite != null) cookieValue += "; SameSite=$sameSite"
34-
35-
return "$cookieValue;"
24+
// Without buildString is empty in wasmJs
25+
override fun toString(): String = buildString {
26+
append("$name=$value")
27+
if (path != null) append("; Path=$path")
28+
// The domain must match the domain of the JavaScript origin. Setting cookies to foreign domains will be silently ignored.
29+
if (domain != null) append("; Domain=$domain")
30+
if (expiresDate != null) append("; Expires=" + getCookieExpirationDate(expiresDate))
31+
if (maxAge != null) append("; Max-Age=$maxAge")
32+
if (isSecure == true) append("; Secure")
33+
if (isHttpOnly == true) append("; HttpOnly")
34+
if (sameSite != null) append("; SameSite=$sameSite")
35+
append(';')
3636
}
3737
}
3838

0 commit comments

Comments
 (0)