From cd8943a3f9e0cbdfe02bdfcdc0393946c9265731 Mon Sep 17 00:00:00 2001 From: Feuerfuchs Date: Mon, 11 Nov 2019 22:04:20 +0100 Subject: Fix: Correctly handle URIs where the type is not separated by a slash --- gopherproxy.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'gopherproxy.go') 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 RawText string Lines []Item Error bool - }{uri, fmt.Sprintf("%s/%s", hostport, uri), assetList, fmt.Sprintf("Error: %s", err), nil, true}) + }{"", hostport, assetList, fmt.Sprintf("Error: %s", err), nil, true}) return } @@ -346,6 +346,17 @@ func ListenAndServe(bind, robotsfile string, robotsdebug bool, vipsconcurrency i var inputStr = fmt.Sprintf("%v", input) return re.ReplaceAllString(inputStr, output) }, + "trimLeftChar": func(s string) string { + for i := range s { + if i > 0 { + return s[i:] + } + } + return s[:0] + }, + "hasPrefix": func(s string, prefix string) bool { + return strings.HasPrefix(s, prefix) + }, } tpl, err = template.New("gophermenu").Funcs(funcMap).Parse(tpltext) -- cgit v1.2.3-54-g00ecf