From 9a31905ff784f7ba598a3aa248950fcb8eeefa1a Mon Sep 17 00:00:00 2001 From: surdeus Date: Sun, 9 Jun 2024 19:47:01 +0500 Subject: [PATCH] fix: fixed wrong extension detection in the handler. --- handler.go | 5 +++-- src/index.htm.tpp | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/handler.go b/handler.go index 8005d2b..00c42b7 100644 --- a/handler.go +++ b/handler.go @@ -108,7 +108,7 @@ func (h *Handler) ServeHTTP( urlPath := r.URL.Path // Cleaning URL path to prevent injections. urlPath = path.Clean(urlPath) - urlExt := path.Ext(urlPath) + //urlExt := path.Ext(urlPath) filePath := filepath.Join( filepath.FromSlash(h.sourcePath), @@ -165,7 +165,8 @@ func (h *Handler) ServeHTTP( // Setting before the code to let it change own // content type? - contentType := mime.TypeByExtension(urlExt) + fileExt := filepath.Ext(filePath) + contentType := mime.TypeByExtension(fileExt) w.Header().Set("Content-Type", contentType) processedData := fileData if shouldProcess { diff --git a/src/index.htm.tpp b/src/index.htm.tpp index 666751c..2b3e556 100644 --- a/src/index.htm.tpp +++ b/src/index.htm.tpp @@ -7,7 +7,10 @@ {{ pp.print( - html.h1().body("This is the example page for THT") + html.h1().body("This is the example page for THT"), + html.p().body( + "Какое-то количество русского текста" + ) ) pp.print("some more shit")