Show local directory index file if available (#319)

This commit is contained in:
Sotiris Papatheodorou 2023-09-28 00:14:35 +02:00 committed by GitHub
parent 818604f582
commit e35ba06cf9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,6 +35,12 @@ func handleFile(u string) (*structs.Page, bool) {
if u[len(u)-1] != '/' { if u[len(u)-1] != '/' {
u += "/" u += "/"
} }
for _, index := range []string{"index.gmi", "index.gemini"} {
m, err := os.Stat(uri.Path + "/" + index)
if err == nil && !m.IsDir() {
return handleFile(u + index)
}
}
return createDirectoryListing(u) return createDirectoryListing(u)
case mode.IsRegular(): case mode.IsRegular():
if fi.Size() > viper.GetInt64("a-general.page_max_size") { if fi.Size() > viper.GetInt64("a-general.page_max_size") {