Skip to content

Commit

Permalink
The community uses index.gmi not index.gemini as a root document.
Browse files Browse the repository at this point in the history
  • Loading branch information
a-h committed Aug 22, 2020
1 parent 442735b commit c76e259
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ openssl ecparam -genkey -name secp384r1 -out server.key
openssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650
# Make a Gemini file.
mkdir content
echo "# Hello, World!" > content/index.gemini
echo "# Hello, World!" > content/index.gmi
# Run the container.
docker pull adrianhesketh/gemini:latest
docker run -v `pwd`:/certs -e PORT=1965 -e DOMAIN=localhost -v `pwd`/content:/content -p 1965:1965 adrianhesketh/gemini:latest
Expand Down
6 changes: 3 additions & 3 deletions filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,16 @@ func FileSystemHandler(fs FileSystem) Handler {
return
}
if stat.IsDir() {
// Look for index.gemini first before listing contents.
// Look for index.gmi first before listing contents.
if !strings.HasSuffix(r.URL.Path, "/") {
r.URL.Path += "/"
}
index, err := fs.Open(r.URL.Path + "index.gemini")
index, err := fs.Open(r.URL.Path + "index.gmi")
if errors.Is(err, os.ErrNotExist) {
DirectoryListingHandler(r.URL.Path, f).ServeGemini(w, r)
return
}
FileContentHandler("index.gemini", index).ServeGemini(w, r)
FileContentHandler("index.gmi", index).ServeGemini(w, r)
return
}
FileContentHandler(stat.Name(), f).ServeGemini(w, r)
Expand Down
14 changes: 7 additions & 7 deletions filesystem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ func TestFileSystemHandler(t *testing.T) {
expectedBody string
}{
{
name: "if a directory contains index.gemini, it is used",
name: "if a directory contains index.gmi, it is used",
url: "/a",
expectedHeader: geminiSuccessHeader,
expectedBody: "# /tests/a/index.gemini\n",
expectedBody: "# /tests/a/index.gmi\n",
},
{
name: "files can be accessed directly",
url: "/a/index.gemini",
url: "/a/index.gmi",
expectedHeader: geminiSuccessHeader,
expectedBody: "# /tests/a/index.gemini\n",
expectedBody: "# /tests/a/index.gmi\n",
},
{
name: "a slash prefix is added if missing",
url: "a/index.gemini",
url: "a/index.gmi",
expectedHeader: geminiSuccessHeader,
expectedBody: "# /tests/a/index.gemini\n",
expectedBody: "# /tests/a/index.gmi\n",
},
{
name: "if a directory does not contain an index, a listing is returned",
Expand All @@ -50,7 +50,7 @@ func TestFileSystemHandler(t *testing.T) {
},
{
name: "directory traversal attacks are deflected",
url: "../a/index.gemini",
url: "../a/index.gmi",
expectedHeader: Header{
Code: CodeBadRequest,
},
Expand Down
2 changes: 1 addition & 1 deletion tests/a/index.gemini
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# /tests/a/index.gemini
# /tests/a/index.gmi
2 changes: 1 addition & 1 deletion tests/b/c/index.gemini
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# tests/b/c/index.gemini
# tests/b/c/index.gmi
2 changes: 1 addition & 1 deletion tests/index.gemini
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# /tests/index.gemini
# /tests/index.gmi

0 comments on commit c76e259

Please sign in to comment.