mirror of
https://github.com/caddyserver/caddy.git
synced 2025-05-28 06:40:01 +08:00
templates: Another context fix when host header is missing port
This commit is contained in:
@ -110,6 +110,10 @@ func (c Context) Host() (string, error) {
|
||||
func (c Context) Port() (string, error) {
|
||||
_, port, err := net.SplitHostPort(c.Req.Host)
|
||||
if err != nil {
|
||||
if !strings.Contains(c.Req.Host, ":") {
|
||||
// common with sites served on the default port 80
|
||||
return "80", nil
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
return port, nil
|
||||
|
Reference in New Issue
Block a user