diff options
author | Feuerfuchs <git@feuerfuchs.dev> | 2019-11-17 11:28:53 +0100 |
---|---|---|
committer | Feuerfuchs <git@feuerfuchs.dev> | 2019-11-17 11:28:53 +0100 |
commit | 4fdfe9af0f5f4c0680a8d4148a276cc300d6c041 (patch) | |
tree | 789088da9bb707eb4cb75fe06abaa85330a07e26 /gopherproxy.go | |
parent | Fox location of default startpage file (diff) | |
download | gopherproxy-4fdfe9af0f5f4c0680a8d4148a276cc300d6c041.tar.gz gopherproxy-4fdfe9af0f5f4c0680a8d4148a276cc300d6c041.tar.bz2 gopherproxy-4fdfe9af0f5f4c0680a8d4148a276cc300d6c041.zip |
Created proper startpage, support gemini:// links in Gopher mode
Diffstat (limited to 'gopherproxy.go')
-rw-r--r-- | gopherproxy.go | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/gopherproxy.go b/gopherproxy.go index a91e057..8c0bb89 100644 --- a/gopherproxy.go +++ b/gopherproxy.go | |||
@@ -96,10 +96,20 @@ func renderGopherDirectory(w http.ResponseWriter, tpl *template.Template, assetL | |||
96 | continue | 96 | continue |
97 | } | 97 | } |
98 | 98 | ||
99 | if strings.HasPrefix(x.Selector, "URL:") { | 99 | if strings.HasPrefix(x.Selector, "URL:") || strings.HasPrefix(x.Selector, "/URL:") { |
100 | tr.Link = template.URL(x.Selector[4:]) | 100 | link := strings.TrimPrefix(strings.TrimPrefix(x.Selector, "/"), "URL:") |
101 | } else if strings.HasPrefix(x.Selector, "/URL:") { | 101 | if strings.HasPrefix(link, "gemini://") { |
102 | tr.Link = template.URL(x.Selector[5:]) | 102 | link = fmt.Sprintf( |
103 | "/gemini/%s", | ||
104 | strings.TrimPrefix(link, "gemini://"), | ||
105 | ) | ||
106 | } else if strings.HasPrefix(link, "gopher://") { | ||
107 | link = fmt.Sprintf( | ||
108 | "/gopher/%s", | ||
109 | strings.TrimPrefix(link, "gopher://"), | ||
110 | ) | ||
111 | } | ||
112 | tr.Link = template.URL(link) | ||
103 | } else { | 113 | } else { |
104 | var hostport string | 114 | var hostport string |
105 | if x.Port == 70 { | 115 | if x.Port == 70 { |