diff options
| author | Mitchell Riedstra <mitch@riedstra.dev> | 2022-10-09 17:00:47 -0400 |
|---|---|---|
| committer | Mitchell Riedstra <mitch@riedstra.dev> | 2022-10-09 17:00:47 -0400 |
| commit | 8ede9f1a44e5b11b2d2b647b03922e17c2331430 (patch) | |
| tree | a2a688918aa7b4100488a4e543dff240fc70e710 | |
| parent | 8e789a73a07d0741e6c53068c517a38bb730c8ba (diff) | |
| download | go-website-8ede9f1a44e5b11b2d2b647b03922e17c2331430.tar.gz go-website-8ede9f1a44e5b11b2d2b647b03922e17c2331430.tar.xz | |
Fix broken 404 page on Windows by using appropriate error checking.
| -rw-r--r-- | page/render.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/page/render.go b/page/render.go index d35ba38..691a258 100644 --- a/page/render.go +++ b/page/render.go @@ -2,9 +2,10 @@ package page import ( "bytes" + "errors" + "io/fs" "net/http" "path/filepath" - "strings" ) func getURLPath(r *http.Request) string { @@ -112,7 +113,7 @@ func Render(w http.ResponseWriter, r *http.Request, err := p.Render(buf) if err != nil { - if strings.HasSuffix(err.Error(), "no such file or directory") { + if errors.Is(err, fs.ErrNotExist) { Render4xx(w, r, vars, http.StatusNotFound) return |
