diff options
-rw-r--r-- | server.go | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -14,6 +14,13 @@ import ( var tmpl *template.Template +func normaliseName( name string ) string { + if len(name) > 27 { + name = name[:25] + "..." + } + return name +} + func getPath( r *http.Request ) string { if r.URL.Path == "/" { return "." @@ -82,9 +89,9 @@ func handleGet( w http.ResponseWriter, r *http.Request, headOnly bool) { } for _, file := range fileInfo { if file.IsDir() { - cols = append(cols, Entry{file.Name(), initPath + file.Name(), 0}) + cols = append(cols, Entry{normaliseName(file.Name()), initPath + file.Name(), 0}) } else { - files = append(files, Entry{file.Name(), initPath + file.Name(), file.Size()}) + files = append(files, Entry{normaliseName(file.Name()), initPath + file.Name(), file.Size()}) } } type Collection struct { |