Merge pull request #4928 from chlins/fix/cookie-path

Always set a default value "/" for Cookie "Path"
This commit is contained in:
jianzhiyao 2022-04-29 17:02:19 +08:00 committed by GitHub
commit 9cd021f27c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -117,13 +117,13 @@ func (output *BeegoOutput) Cookie(name string, value string, others ...interface
// can use nil skip set
// default "/"
tmpPath := "/"
if len(others) > 1 {
if v, ok := others[1].(string); ok && len(v) > 0 {
fmt.Fprintf(&b, "; Path=%s", sanitizeValue(v))
tmpPath = sanitizeValue(v)
}
} else {
fmt.Fprintf(&b, "; Path=%s", "/")
}
fmt.Fprintf(&b, "; Path=%s", tmpPath)
// default empty
if len(others) > 2 {