Skip to content

Commit

Permalink
headers: Trim any trailing colon from field names as a courtesy
Browse files Browse the repository at this point in the history
  • Loading branch information
mholt committed Mar 30, 2020
1 parent 105acfa commit 37aa516
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions modules/caddyhttp/headers/caddyfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ func parseReqHdrCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler,
return nil, h.ArgErr()
}
field := h.Val()

// sometimes it is habitual for users to suffix a field name with a colon,
// as if they were writing a curl command or something; see
// https://caddy.community/t/v2-reverse-proxy-please-add-cors-example-to-the-docs/7349
field = strings.TrimSuffix(field, ":")

var value, replacement string
if h.NextArg() {
value = h.Val()
Expand Down

0 comments on commit 37aa516

Please sign in to comment.