From d869a375abec092b0234953d70ff02ea393d4780 Mon Sep 17 00:00:00 2001 From: Seednode Date: Sun, 10 Sep 2023 11:27:55 -0500 Subject: [PATCH] Removed redundant isImage check --- cmd/root.go | 2 +- cmd/web.go | 20 ++++++++------------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 2f34c1e..92a6302 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -17,7 +17,7 @@ var ( ) const ( - Version string = "0.59.3" + Version string = "0.59.4" ) var ( diff --git a/cmd/web.go b/cmd/web.go index 1d41653..b639bd7 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -990,17 +990,13 @@ func serveImage(paths []string, Regexes *Regexes, index *Index) httprouter.Handl return } - var dimensions *Dimensions + dimensions, err := imageDimensions(filePath) + if err != nil { + fmt.Println(err) - if image { - dimensions, err = imageDimensions(filePath) - if err != nil { - fmt.Println(err) + serverError(w, r, nil) - serverError(w, r, nil) - - return - } + return } fileName := filepath.Base(filePath) @@ -1114,7 +1110,7 @@ func ServePage(args []string) error { list: []string{}, } - Regexes := &Regexes{ + regexes := &Regexes{ filename: regexp.MustCompile(`(.+)([0-9]{3})(\..+)`), alphanumeric: regexp.MustCompile(`^[A-z0-9]*$`), } @@ -1137,13 +1133,13 @@ func ServePage(args []string) error { mux.PanicHandler = serverErrorHandler() - mux.GET("/", serveRoot(paths, Regexes, index)) + mux.GET("/", serveRoot(paths, regexes, index)) mux.GET("/favicons/*favicon", serveFavicons()) mux.GET("/favicon.ico", serveFavicons()) - mux.GET(ImagePrefix+"/*image", serveImage(paths, Regexes, index)) + mux.GET(ImagePrefix+"/*image", serveImage(paths, regexes, index)) mux.GET(SourcePrefix+"/*static", serveStaticFile(paths, stats, index))