diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2019-06-04 22:26:09 +0000 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2019-08-28 18:38:52 +0000 |
| commit | 7ed973b4d9dab38347f34e87febf3c8659160ce6 (patch) | |
| tree | 9a398d0a24aee47847b791b1458f2c1811d07184 /src/net/http/fs.go | |
| parent | b3a1205a1133328068f002dd44141cb9efb2127b (diff) | |
| download | go-7ed973b4d9dab38347f34e87febf3c8659160ce6.tar.xz | |
net/http: don't panic serving dir in ServeFile with empty Request.URL.Path
Updates #30165
Updates #31622
Change-Id: I7a4b91aa7c5c3af8c0b1273cbb42046feddf7d78
Reviewed-on: https://go-review.googlesource.com/c/go/+/180499
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/net/http/fs.go')
| -rw-r--r-- | src/net/http/fs.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/net/http/fs.go b/src/net/http/fs.go index 41d46dced2..4c4f0e429e 100644 --- a/src/net/http/fs.go +++ b/src/net/http/fs.go @@ -585,7 +585,7 @@ 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 - if url[len(url)-1] != '/' { + if url == "" || url[len(url)-1] != '/' { localRedirect(w, r, path.Base(url)+"/") return } |
