case insensitive indexing

This commit is contained in:
Pierre Dubouilh 2020-01-18 16:33:10 +01:00
parent b2e0396cf1
commit be39e6aca8
No known key found for this signature in database
GPG key ID: 10E1A7CE67E74C0F

View file

@ -14,6 +14,7 @@ import (
"net/url" "net/url"
"os" "os"
"path/filepath" "path/filepath"
"sort"
"strconv" "strconv"
"strings" "strings"
) )
@ -79,6 +80,7 @@ func humanize(bytes int64) string {
func replyList(w http.ResponseWriter, fullPath string, path string) { func replyList(w http.ResponseWriter, fullPath string, path string) {
_files, err := ioutil.ReadDir(fullPath) _files, err := ioutil.ReadDir(fullPath)
check(err) check(err)
sort.Slice(_files, func(i, j int) bool { return strings.ToLower(_files[i].Name()) < strings.ToLower(_files[j].Name()) })
if !strings.HasSuffix(path, "/") { if !strings.HasSuffix(path, "/") {
path += "/" path += "/"