fs: Avoid equality check if lengths don't match

This commit is contained in:
Adnan Maolood 2021-04-21 12:48:16 -04:00
parent c85759d777
commit 1170e007d4

2
fs.go
View File

@ -67,7 +67,7 @@ func (fsys fileServer) ServeGemini(ctx context.Context, w ResponseWriter, r *Req
if target != "/" {
target += "/"
}
if r.URL.Path != target {
if len(r.URL.Path) != len(target) || r.URL.Path != target {
w.WriteHeader(StatusPermanentRedirect, target)
return
}