From ecd69cdbf454097c3d3acf8eee162a0513c9743f Mon Sep 17 00:00:00 2001 From: Mostafa Razavi Date: Tue, 9 May 2023 18:04:13 +0200 Subject: [PATCH] Fix possible crash --- pkg/hodhod/static.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/hodhod/static.go b/pkg/hodhod/static.go index de64353..28d4bde 100644 --- a/pkg/hodhod/static.go +++ b/pkg/hodhod/static.go @@ -74,10 +74,10 @@ func NewFileResp(filename string, req Request, cfg *Config) (resp Response) { } u := *req.Url - if isDir && u.Path[len(u.Path)-1] != '/' { + if isDir && u.Path != "" && u.Path[len(u.Path)-1] != '/' { u.Path = u.Path + "/" return NewPermRedirectResp(u.String()) - } else if !isDir && u.Path[len(u.Path)-1] == '/' { + } else if !isDir && u.Path != "" && u.Path[len(u.Path)-1] == '/' { u.Path = u.Path[:len(u.Path)-1] return NewPermRedirectResp(u.String()) } -- 2.38.5