From f85930d875494c043fc5ac3ddcf843ddfac14ec9 Mon Sep 17 00:00:00 2001 From: tjpcc Date: Mon, 30 Oct 2023 11:57:04 -0600 Subject: spartan support in fs and cgi contribs fixes #17 --- contrib/fs/gemini.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'contrib/fs/gemini.go') diff --git a/contrib/fs/gemini.go b/contrib/fs/gemini.go index 1fb4e20..79dcc63 100644 --- a/contrib/fs/gemini.go +++ b/contrib/fs/gemini.go @@ -127,17 +127,17 @@ func GeminiDirectoryDefault(fsroot, urlroot string, filenames ...string) sr.Hand fsroot = strings.TrimRight(fsroot, "/") return sr.HandlerFunc(func(ctx context.Context, request *sr.Request) *sr.Response { + if !strings.HasPrefix(request.Path, urlroot) { + return nil + } + if !strings.HasSuffix(request.Path, "/") { u := *request.URL u.Path += "/" return gemini.PermanentRedirect(u.String()) } - if !strings.HasPrefix(request.Path, urlroot) { - return nil - } requestpath := strings.Trim(strings.TrimPrefix(request.Path, urlroot), "/") - fpath := filepath.Join(fsroot, requestpath) if isPrivate(fpath) { return nil -- cgit v1.2.3