Skip to content

Commit

Permalink
fix: fix panic when accessing nonexistent .js file in static path (#1105
Browse files Browse the repository at this point in the history
)
  • Loading branch information
xeizmendi committed Oct 2, 2020
1 parent 4c2a094 commit ad99bf1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion http/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,14 @@ func handleWithStaticData(w http.ResponseWriter, _ *http.Request, d *data, box *

data["Json"] = string(b)

index := template.Must(template.New("index").Delims("[{[", "]}]").Parse(box.MustString(file)))
fileContents, err := box.String(file)
if err != nil {
if err == os.ErrNotExist {
return http.StatusNotFound, err
}
return http.StatusInternalServerError, err
}
index := template.Must(template.New("index").Delims("[{[", "]}]").Parse(fileContents))
err = index.Execute(w, data)
if err != nil {
return http.StatusInternalServerError, err
Expand Down

0 comments on commit ad99bf1

Please sign in to comment.