@cryptotaxi247 / kubo / commits / 58d401c3b

core/corehttp: gateway_handler: Redirect to path with trailing slash when showing a directory's index.html

Matt Bell committed Jan 27, 2015 at 00:21 UTC 58d401c3b0b0ab4e3712641f75e217e1a032fa0b
1 file changed +5
core/corehttp/gateway_handler.go
+5
@@ -144,6 +144,11 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
144 foundIndex := false
145 for _, link := range nd.Links {
146 if link.Name == "index.html" {
147 + if urlPath[len(urlPath)-1] != '/' {
148 + http.Redirect(w, r, urlPath+"/", 302)
149 + return
150 + }
151 +
152 log.Debug("found index")
153 foundIndex = true
154 // return index page instead.