fs: Prevent invalid directory links

A file with a name like "gemini:example" would previously result in the
following invalid link:

    => gemini:example gemini:example

Fix by prepending a "./" before each filename, so that the resulting
link looks like:

    => ./gemini:example gemini:example
This commit is contained in:
Adnan Maolood 2022-05-07 13:51:28 -04:00
parent 8c0af18617
commit b0f27c6f74

2
fs.go
View File

@ -169,7 +169,7 @@ func dirList(w ResponseWriter, f fs.File) {
}
link := LineLink{
Name: name,
URL: (&url.URL{Path: name}).EscapedPath(),
URL: "./" + url.PathEscape(name),
}
fmt.Fprintln(w, link.String())
}