It seems that when a Gemini URL without a trailing slash but
corresponding to a directory is requested it's not redirected to the
same URL with a trailing slash. For example
gemini://sotiris.papatheodorou.xyz/gemlog isn't redirected to
gemini://sotiris.papatheodorou.xyz/gemlog/ as expected.
This behavior breaks relative links in the response since they're rooted
on gemini://sotiris.papatheodorou.xyz/ instead of on
gemini://sotiris.papatheodorou.xyz/gemlog/.
I've got a patch that might fix this issue (pasted below) but no easy
way to test it. I have managed to package the patched version (by
modifying a manifest from some build on lists.sr.ht) but I'm not sure
how to test that the issue is fixed.
https://builds.sr.ht/~sotirisp/job/1152014
Any help is welcome.
Sotiris
---
server.go | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/server.go b/server.go
index 8a0266b..396d5b6 100644
--- a/server.go
+++ b/server.go
@@ -357,6 +357,10 @@ func ServeGemini(conf ini.File, db *sql.DB, mc *minio.Client) *gemini.Server {
if err != nil {
panic(err)
}
+ if strings.HasSuffix(s3path, "index.gmi") && !strings.HasSuffix(r.URL.Path, "/") {
+ w.WriteHeader(gemini.StatusPermanentRedirect, r.URL.String()+"/")
+ return
+ }
break
}
--
2.25.1