mirror of
https://github.com/golang/go
synced 2024-11-23 09:50:03 -07:00
net/http: merge IsDir checks in fs.go's serveFile function
Fixes #33385
This commit is contained in:
parent
fa7d40abe0
commit
3bf483808e
@ -582,17 +582,15 @@ func serveFile(w ResponseWriter, r *Request, fs FileSystem, name string, redirec
|
||||
}
|
||||
}
|
||||
|
||||
// redirect if the directory name doesn't end in a slash
|
||||
if d.IsDir() {
|
||||
url := r.URL.Path
|
||||
// redirect if the directory name doesn't end in a slash
|
||||
if url == "" || url[len(url)-1] != '/' {
|
||||
localRedirect(w, r, path.Base(url)+"/")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// use contents of index.html for directory, if present
|
||||
if d.IsDir() {
|
||||
// use contents of index.html for directory, if present
|
||||
index := strings.TrimSuffix(name, "/") + indexPage
|
||||
ff, err := fs.Open(index)
|
||||
if err == nil {
|
||||
|
Loading…
Reference in New Issue
Block a user