Skip to content

Commit

Permalink
#234 splitCookie needn't be public
Browse files Browse the repository at this point in the history
  • Loading branch information
bnfinet committed Apr 8, 2020
1 parent 6ad7357 commit 6e5a6c9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pkg/cookie/cookie.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func setCookie(w http.ResponseWriter, r *http.Request, val string, maxAge int) {
if cookieSize > maxCookieSize {
// https://www.lifewire.com/cookie-limit-per-domain-3466809
log.Warnf("cookie size: %d. cookie sizes over ~4093 bytes(depending on the browser and platform) have shown to cause issues or simply aren't supported.", cookieSize)
cookieParts := SplitCookie(val, maxCookieSize-emptyCookieSize)
cookieParts := splitCookie(val, maxCookieSize-emptyCookieSize)
for i, cookiePart := range cookieParts {
// Cookies are named 1of3, 2of3, 3of3
cookieName = fmt.Sprintf("%s_%dof%d", cfg.Cfg.Cookie.Name, i+1, len(cookieParts))
Expand Down Expand Up @@ -152,8 +152,8 @@ func ClearCookie(w http.ResponseWriter, r *http.Request) {
}
}

// SplitCookie separate string into several strings of specified length
func SplitCookie(longString string, maxLen int) []string {
// splitCookie separate string into several strings of specified length
func splitCookie(longString string, maxLen int) []string {
splits := make([]string, 0)

var l, r int
Expand Down
6 changes: 3 additions & 3 deletions pkg/cookie/cookie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/vouch/vouch-proxy/pkg/cfg"
)

func TestSplitCookie(t *testing.T) {
func TestsplitCookie(t *testing.T) {
type args struct {
longString string
maxLen int
Expand All @@ -23,8 +23,8 @@ func TestSplitCookie(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := SplitCookie(tt.args.longString, tt.args.maxLen); !reflect.DeepEqual(got, tt.want) {
t.Errorf("SplitCookie() = %v, want %v", got, tt.want)
if got := splitCookie(tt.args.longString, tt.args.maxLen); !reflect.DeepEqual(got, tt.want) {
t.Errorf("splitCookie() = %v, want %v", got, tt.want)
}
})
}
Expand Down

0 comments on commit 6e5a6c9

Please sign in to comment.