Don't include :port if the server is onthe default port 70

This commit is contained in:
James Mills 2016-09-26 23:21:56 +10:00
parent db99f5876a
commit 4c66260eec
No known key found for this signature in database
GPG Key ID: AC4C014F1440EBD6
1 changed files with 7 additions and 1 deletions

View File

@ -44,10 +44,16 @@ func renderDirectory(w http.ResponseWriter, tpl *template.Template, hostport str
if strings.HasPrefix(x.Selector, "URL:") {
tr.Link = template.URL(x.Selector[4:])
} else {
var hostport string
if x.Port == 70 {
hostport = x.Host
} else {
hostport = fmt.Sprintf("%s:%d", x.Host, x.Port)
}
tr.Link = template.URL(
fmt.Sprintf(
"/%s/%s%s",
fmt.Sprintf("%s:%d", x.Host, x.Port),
hostport,
string(byte(x.Type)),
url.QueryEscape(x.Selector),
),