From 326fea768a5a1122e1cc70206abff6dda89cc048 Mon Sep 17 00:00:00 2001 From: zh199225 Date: Fri, 20 Aug 2021 09:23:03 +0800 Subject: [PATCH] Always set a default value "/" for Cookie "Path" When the URL is end with "/", and the parameter "Path" of SetCookie() Function is "", the "Path" of cookie that set in browser will not be the default value "/"., I think it's incorrect. When the URL is not end with "/", it's correct. --- server/web/context/output.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/web/context/output.go b/server/web/context/output.go index 0c261627..f52eac9d 100644 --- a/server/web/context/output.go +++ b/server/web/context/output.go @@ -118,13 +118,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 {