Removed redundant isImage check

This commit is contained in:
Seednode 2023-09-10 11:27:55 -05:00
parent 30eead7e2f
commit d869a375ab
2 changed files with 9 additions and 13 deletions

View File

@ -17,7 +17,7 @@ var (
) )
const ( const (
Version string = "0.59.3" Version string = "0.59.4"
) )
var ( var (

View File

@ -990,10 +990,7 @@ func serveImage(paths []string, Regexes *Regexes, index *Index) httprouter.Handl
return return
} }
var dimensions *Dimensions dimensions, err := imageDimensions(filePath)
if image {
dimensions, err = imageDimensions(filePath)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
@ -1001,7 +998,6 @@ func serveImage(paths []string, Regexes *Regexes, index *Index) httprouter.Handl
return return
} }
}
fileName := filepath.Base(filePath) fileName := filepath.Base(filePath)
@ -1114,7 +1110,7 @@ func ServePage(args []string) error {
list: []string{}, list: []string{},
} }
Regexes := &Regexes{ regexes := &Regexes{
filename: regexp.MustCompile(`(.+)([0-9]{3})(\..+)`), filename: regexp.MustCompile(`(.+)([0-9]{3})(\..+)`),
alphanumeric: regexp.MustCompile(`^[A-z0-9]*$`), alphanumeric: regexp.MustCompile(`^[A-z0-9]*$`),
} }
@ -1137,13 +1133,13 @@ func ServePage(args []string) error {
mux.PanicHandler = serverErrorHandler() mux.PanicHandler = serverErrorHandler()
mux.GET("/", serveRoot(paths, Regexes, index)) mux.GET("/", serveRoot(paths, regexes, index))
mux.GET("/favicons/*favicon", serveFavicons()) mux.GET("/favicons/*favicon", serveFavicons())
mux.GET("/favicon.ico", 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)) mux.GET(SourcePrefix+"/*static", serveStaticFile(paths, stats, index))