Skip to content

Commit

Permalink
fix(cookie): Remove partitioned field
Browse files Browse the repository at this point in the history
The partitioned field is only available in go 1.23+ and so
should be removed from the library as this version does not
yet require v1.23+.

See golang/go#62490 (comment)

Fixes #277
  • Loading branch information
jaitaiwan committed Jun 15, 2024
1 parent c373b3e commit 19d52f4
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 18 deletions.
1 change: 0 additions & 1 deletion cookie.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ func newCookieFromOptions(name, value string, options *Options) *http.Cookie {
MaxAge: options.MaxAge,
Secure: options.Secure,
HttpOnly: options.HttpOnly,
Partitioned: options.Partitioned,
}

}
1 change: 0 additions & 1 deletion cookie_go111.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ func newCookieFromOptions(name, value string, options *Options) *http.Cookie {
Secure: options.Secure,
HttpOnly: options.HttpOnly,
SameSite: options.SameSite,
Partitioned: options.Partitioned,
}

}
21 changes: 8 additions & 13 deletions cookie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ func TestNewCookieFromOptions(t *testing.T) {
maxAge int
secure bool
httpOnly bool
partitioned bool
}{
{"", "bar", "/foo/bar", "foo.example.com", 3600, true, true, true},
{"foo", "", "/foo/bar", "foo.example.com", 3600, true, true, true},
{"foo", "bar", "", "foo.example.com", 3600, true, true, true},
{"foo", "bar", "/foo/bar", "", 3600, true, true, true},
{"foo", "bar", "/foo/bar", "foo.example.com", 0, true, true, true},
{"foo", "bar", "/foo/bar", "foo.example.com", 3600, false, true, true},
{"foo", "bar", "/foo/bar", "foo.example.com", 3600, true, false, true},
{"foo", "bar", "/foo/bar", "foo.example.com", 3600, true, true, false},
{"", "bar", "/foo/bar", "foo.example.com", 3600, true, true},
{"foo", "", "/foo/bar", "foo.example.com", 3600, true, true},
{"foo", "bar", "", "foo.example.com", 3600, true, true},
{"foo", "bar", "/foo/bar", "", 3600, true, true},
{"foo", "bar", "/foo/bar", "foo.example.com", 0, true, true},
{"foo", "bar", "/foo/bar", "foo.example.com", 3600, false, true},
{"foo", "bar", "/foo/bar", "foo.example.com", 3600, true, false},
{"foo", "bar", "/foo/bar", "foo.example.com", 3600, true, true},
}
for i, v := range tests {
options := &Options{
Expand All @@ -32,7 +31,6 @@ func TestNewCookieFromOptions(t *testing.T) {
MaxAge: v.maxAge,
Secure: v.secure,
HttpOnly: v.httpOnly,
Partitioned: v.partitioned,
}
cookie := newCookieFromOptions(v.name, v.value, options)
if cookie.Name != v.name {
Expand All @@ -56,8 +54,5 @@ func TestNewCookieFromOptions(t *testing.T) {
if cookie.HttpOnly != v.httpOnly {
t.Fatalf("%v: bad cookie httpOnly: got %v, want %v", i+1, cookie.HttpOnly, v.httpOnly)
}
if cookie.Partitioned != v.partitioned {
t.Fatalf("%v: bad cookie partitioned: got %v, want %v", i+1, cookie.Partitioned, v.partitioned)
}
}
}
1 change: 0 additions & 1 deletion options.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ type Options struct {
MaxAge int
Secure bool
HttpOnly bool
Partitioned bool
}
1 change: 0 additions & 1 deletion options_go111.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ type Options struct {
MaxAge int
Secure bool
HttpOnly bool
Partitioned bool
// Defaults to http.SameSiteDefaultMode
SameSite http.SameSite
}
1 change: 0 additions & 1 deletion vendor/github.com/gorilla/securecookie/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 19d52f4

Please sign in to comment.