aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Mills <prologic@shortcircuit.net.au>2016-09-26 23:21:56 +1000
committerJames Mills <prologic@shortcircuit.net.au>2016-09-26 23:21:56 +1000
commit4c66260eecfecc531c526df40881ef51cf82ef46 (patch)
tree924a0f13c04df6b8c0609e3890369a4f14c74abd
parentFixed URI handling (diff)
downloadgopherproxy-4c66260eecfecc531c526df40881ef51cf82ef46.tar.gz
gopherproxy-4c66260eecfecc531c526df40881ef51cf82ef46.tar.bz2
gopherproxy-4c66260eecfecc531c526df40881ef51cf82ef46.zip
Don't include :port if the server is onthe default port 70
-rw-r--r--main.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/main.go b/main.go
index d1557f6..913b0a2 100644
--- a/main.go
+++ b/main.go
@@ -44,10 +44,16 @@ func renderDirectory(w http.ResponseWriter, tpl *template.Template, hostport str
44 if strings.HasPrefix(x.Selector, "URL:") { 44 if strings.HasPrefix(x.Selector, "URL:") {
45 tr.Link = template.URL(x.Selector[4:]) 45 tr.Link = template.URL(x.Selector[4:])
46 } else { 46 } else {
47 var hostport string
48 if x.Port == 70 {
49 hostport = x.Host
50 } else {
51 hostport = fmt.Sprintf("%s:%d", x.Host, x.Port)
52 }
47 tr.Link = template.URL( 53 tr.Link = template.URL(
48 fmt.Sprintf( 54 fmt.Sprintf(
49 "/%s/%s%s", 55 "/%s/%s%s",
50 fmt.Sprintf("%s:%d", x.Host, x.Port), 56 hostport,
51 string(byte(x.Type)), 57 string(byte(x.Type)),
52 url.QueryEscape(x.Selector), 58 url.QueryEscape(x.Selector),
53 ), 59 ),