Skip to content

Commit 0855ae6

Browse files
committed
Don't panic if r.URL.Path is ""
No idea when that happens; I can't repro it in netcat, but I have two panics in the error log (from clearly doctored requests). Still, no reason to not be safer.
1 parent d5ada75 commit 0855ae6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

handlers/website.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ func (h website) openAPI(w http.ResponseWriter, r *http.Request) error {
228228
}
229229

230230
func (h website) tpl(w http.ResponseWriter, r *http.Request) error {
231-
t := path.Base(r.URL.Path[1:])
231+
t := strings.Trim(r.URL.Path, "/")
232232
if t == "" || t == "." {
233233
t = "home"
234234
}

0 commit comments

Comments
 (0)