You've already forked oauth2-proxy
mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2025-11-29 22:48:19 +02:00
Some code improvements
* Remove shadowing of predeclared identifier: new. * strings.ReplaceAll instead of strings.Replace with -1. * Change strings.ToLower comparison to strings.EqualFold. * Rewrite if-else-if-else chain as a switch.
This commit is contained in:
@@ -136,18 +136,18 @@ func splitCookie(c *http.Cookie) []*http.Cookie {
|
||||
valueBytes := []byte(c.Value)
|
||||
count := 0
|
||||
for len(valueBytes) > 0 {
|
||||
new := copyCookie(c)
|
||||
new.Name = fmt.Sprintf("%s_%d", c.Name, count)
|
||||
newCookie := copyCookie(c)
|
||||
newCookie.Name = fmt.Sprintf("%s_%d", c.Name, count)
|
||||
count++
|
||||
if len(valueBytes) < maxCookieLength {
|
||||
new.Value = string(valueBytes)
|
||||
newCookie.Value = string(valueBytes)
|
||||
valueBytes = []byte{}
|
||||
} else {
|
||||
newValue := valueBytes[:maxCookieLength]
|
||||
valueBytes = valueBytes[maxCookieLength:]
|
||||
new.Value = string(newValue)
|
||||
newCookie.Value = string(newValue)
|
||||
}
|
||||
cookies = append(cookies, new)
|
||||
cookies = append(cookies, newCookie)
|
||||
}
|
||||
return cookies
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user