Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Engelhardt <flo@dotbox.org>2020-09-16 11:44:53 +0300
committerFlorian Engelhardt <flo@dotbox.org>2020-10-20 14:10:46 +0300
commit88da6de0d06eee4dddd06e41466e6c1ee869e045 (patch)
tree8369a21477ba71b429c63399e32be27acee61d98
parent05c6facd72644095ca1aeff88c564dfb411fe34f (diff)
#460 add handling for avif file format
-rw-r--r--internal/serving/disk/helpers.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/internal/serving/disk/helpers.go b/internal/serving/disk/helpers.go
index 5456724a..f11c07b3 100644
--- a/internal/serving/disk/helpers.go
+++ b/internal/serving/disk/helpers.go
@@ -39,7 +39,8 @@ func endsWithoutHTMLExtension(path string) bool {
// Implementation is adapted from Golang's `http.serveContent()`
// See https://github.com/golang/go/blob/902fc114272978a40d2e65c2510a18e870077559/src/net/http/fs.go#L194
func (reader *Reader) detectContentType(ctx context.Context, root vfs.Root, path string) (string, error) {
- contentType := mime.TypeByExtension(filepath.Ext(path))
+ fileExt := filepath.Ext(path)
+ contentType := mime.TypeByExtension(fileExt)
if contentType == "" {
var buf [512]byte
@@ -57,6 +58,10 @@ func (reader *Reader) detectContentType(ctx context.Context, root vfs.Root, path
contentType = http.DetectContentType(buf[:n])
}
+ if contentType == "application/octet-stream" && fileExt == ".avif" {
+ contentType = "image/avif"
+ }
+
return contentType, nil
}