serveHtmlHandler could potentially return an empty response in default case
This commit is contained in:
parent
f3280a6b6c
commit
9e05a12fd7
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var Version = "0.8.0"
|
||||
var Version = "0.8.1"
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(versionCmd)
|
||||
|
|
12
cmd/web.go
12
cmd/web.go
|
@ -136,12 +136,12 @@ func serveHtmlHandler(paths []string) http.HandlerFunc {
|
|||
|
||||
switch {
|
||||
case r.RequestURI == "/" && Successive && refererUri != "":
|
||||
f, err := url.QueryUnescape(refererUri)
|
||||
query, err := url.QueryUnescape(refererUri)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
filePath, err = getNextFile(f)
|
||||
filePath, err = getNextFile(query)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -189,18 +189,20 @@ func serveHtmlHandler(paths []string) http.HandlerFunc {
|
|||
|
||||
isImage, err := checkIfImage(filePath)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if !isImage {
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
|
||||
if isImage {
|
||||
err := serveHtml(w, *r, filePath)
|
||||
err = serveHtml(w, *r, filePath)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func doNothing(http.ResponseWriter, *http.Request) {}
|
||||
|
||||
|
|
Loading…
Reference in New Issue