templates: Parse host successfully when port is implicit (fixes #292)

This commit is contained in:
Matthew Holt
2015-10-27 23:20:05 -06:00
parent 136119f8ac
commit cc229aefae
2 changed files with 15 additions and 1 deletions

View File

@ -97,6 +97,10 @@ func (c Context) URI() string {
func (c Context) Host() (string, error) {
host, _, 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 c.Req.Host, nil
}
return "", err
}
return host, nil