From 3a7077d0f92998e932cd249e1ea85fad35e85ba2 Mon Sep 17 00:00:00 2001 From: tjpcc Date: Sat, 23 Sep 2023 13:17:17 -0600 Subject: use gopher.GuessItemType on blobs --- gopher.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/gopher.go b/gopher.go index 196c1d0..3ad5ed2 100644 --- a/gopher.go +++ b/gopher.go @@ -135,16 +135,9 @@ func gopherTreePath(tmpl *template.Template, haspath bool) sliderule.Handler { } filetype := gopher.MenuType - ext := path.Ext(params["path"]) - if ext != ".gph" && params["path"] != "gophermap" { - mtype := mime.TypeByExtension(ext) - if strings.HasPrefix(mtype, "text/") { - filetype = gopher.TextFileType - } else { - filetype = gopher.BinaryFileType - } + if path.Base(params["path"]) != "gophermap" { + filetype = gopher.GuessItemType(params["path"]) } - return gopher.File(filetype, bytes.NewBuffer(body)) }) } -- cgit v1.2.3