diff options
author | Feuerfuchs <git@feuerfuchs.dev> | 2019-11-11 22:04:20 +0100 |
---|---|---|
committer | Feuerfuchs <git@feuerfuchs.dev> | 2019-11-11 22:04:20 +0100 |
commit | cd8943a3f9e0cbdfe02bdfcdc0393946c9265731 (patch) | |
tree | 4c10ed5ce71d3ff9d13f626877507bde904e7098 /gopherproxy.go | |
parent | Prefix instead of equality to determine page type (diff) | |
download | gopherproxy-cd8943a3f9e0cbdfe02bdfcdc0393946c9265731.tar.gz gopherproxy-cd8943a3f9e0cbdfe02bdfcdc0393946c9265731.tar.bz2 gopherproxy-cd8943a3f9e0cbdfe02bdfcdc0393946c9265731.zip |
Fix: Correctly handle URIs where the type is not separated by a slash
Diffstat (limited to 'gopherproxy.go')
-rw-r--r-- | gopherproxy.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/gopherproxy.go b/gopherproxy.go index 8b33c05..d98ef7c 100644 --- a/gopherproxy.go +++ b/gopherproxy.go | |||
@@ -132,7 +132,7 @@ func GopherHandler(tpl *template.Template, robotsdata *robotstxt.RobotsData, ass | |||
132 | RawText string | 132 | RawText string |
133 | Lines []Item | 133 | Lines []Item |
134 | Error bool | 134 | Error bool |
135 | }{uri, fmt.Sprintf("%s/%s", hostport, uri), assetList, fmt.Sprintf("Error: %s", err), nil, true}) | 135 | }{"", hostport, assetList, fmt.Sprintf("Error: %s", err), nil, true}) |
136 | return | 136 | return |
137 | } | 137 | } |
138 | 138 | ||
@@ -346,6 +346,17 @@ func ListenAndServe(bind, robotsfile string, robotsdebug bool, vipsconcurrency i | |||
346 | var inputStr = fmt.Sprintf("%v", input) | 346 | var inputStr = fmt.Sprintf("%v", input) |
347 | return re.ReplaceAllString(inputStr, output) | 347 | return re.ReplaceAllString(inputStr, output) |
348 | }, | 348 | }, |
349 | "trimLeftChar": func(s string) string { | ||
350 | for i := range s { | ||
351 | if i > 0 { | ||
352 | return s[i:] | ||
353 | } | ||
354 | } | ||
355 | return s[:0] | ||
356 | }, | ||
357 | "hasPrefix": func(s string, prefix string) bool { | ||
358 | return strings.HasPrefix(s, prefix) | ||
359 | }, | ||
349 | } | 360 | } |
350 | 361 | ||
351 | tpl, err = template.New("gophermenu").Funcs(funcMap).Parse(tpltext) | 362 | tpl, err = template.New("gophermenu").Funcs(funcMap).Parse(tpltext) |