Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit d30cebc

Browse files
committed
Fix cookie conversions to/from Goja
Goja cannot convert a JavaScript value provided by the user into an api.Cookie type. While converting, Goja misses the api.CookieSameSite and httpOnly. The underlying reason is the missing `js` struct tag.
1 parent 202dd3a commit d30cebc

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

api/browser_context.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,16 @@ type BrowserContext interface {
4141
//
4242
// https://datatracker.ietf.org/doc/html/rfc6265.
4343
type Cookie struct {
44-
Name string `json:"name"` // Cookie name.
45-
Value string `json:"value"` // Cookie value.
46-
Domain string `json:"domain"` // Cookie domain.
47-
Path string `json:"path"` // Cookie path.
48-
Expires int64 `json:"expires"` // Cookie expiration date as the number of seconds since the UNIX epoch.
49-
HTTPOnly bool `json:"httpOnly"` // True if cookie is http-only.
50-
Secure bool `json:"secure"` // True if cookie is secure.
51-
SameSite CookieSameSite `json:"sameSite"` // Cookie SameSite type.
52-
URL string `json:"url,omitempty"` // Cookie URL.
44+
Name string `json:"name"` // Cookie name.
45+
Value string `json:"value"` // Cookie value.
46+
Domain string `json:"domain"` // Cookie domain.
47+
Path string `json:"path"` // Cookie path.
48+
HTTPOnly bool `js:"httpOnly" json:"httpOnly"` // True if cookie is http-only.
49+
Secure bool `json:"secure"` // True if cookie is secure.
50+
SameSite CookieSameSite `js:"sameSite" json:"sameSite"` // Cookie SameSite type.
51+
URL string `js:"url" json:"url,omitempty"` // Cookie URL.
52+
// Cookie expiration date as the number of seconds since the UNIX epoch.
53+
Expires int64 `json:"expires"`
5354
}
5455

5556
// CookieSameSite represents the cookie's 'SameSite' status.

0 commit comments

Comments
 (0)