diff options
author | tjpcc <tjp@ctrl-c.club> | 2023-10-30 11:57:04 -0600 |
---|---|---|
committer | tjpcc <tjp@ctrl-c.club> | 2023-10-30 11:57:04 -0600 |
commit | f85930d875494c043fc5ac3ddcf843ddfac14ec9 (patch) | |
tree | d905a0d8a8b9d8277c4d3949b9500e44999f452e /contrib/fs/gemini.go | |
parent | 629956103b945e1596bab5c5dea163e849a8bf73 (diff) |
spartan support in fs and cgi contribs
fixes #17
Diffstat (limited to 'contrib/fs/gemini.go')
-rw-r--r-- | contrib/fs/gemini.go | 8 |
1 files changed, 4 insertions, 4 deletions
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 |