@@ 106,11 106,6 @@ func route(conn io.ReadWriteCloser) {
[]byte("/home/$1/"+config.UserDir+"$2")))
} else {
path = config.IndexDir + address.Path
-
- // remove trailing slash
- if strings.HasSuffix(path, "/") {
- path = path[:len(path)-1]
- }
}
// add index.gmi if path not found and index exists
@@ 121,6 116,12 @@ func route(conn io.ReadWriteCloser) {
sendResponseHeader(conn, 20, "text/plain")
}
} else if exists(path + "/index.gmi") {
+ // request trailing slash
+ if !strings.HasSuffix(path, "/") {
+ log.Println("directory index found, requesting trailing slash")
+ sendResponseHeader(conn, 31, address.Path+"/")
+ return
+ }
path += "/index.gmi"
sendResponseHeader(conn, 20, "text/gemini; lang=en; charset=utf-8")
} else {