newui: redirect /ui/new to /ui/new/

Change-Id: I2686a3e577a32436d55e7cf5fd6640d1717caac5
This commit is contained in:
Brad Fitzpatrick 2013-01-20 12:33:15 -08:00
parent e889394a74
commit f696b164f4
1 changed files with 6 additions and 0 deletions

View File

@ -408,12 +408,18 @@ func (ui *UIHandler) serveFileTree(rw http.ResponseWriter, req *http.Request) {
}
func (ui *UIHandler) serveNewUI(rw http.ResponseWriter, req *http.Request) {
base := req.Header.Get("X-PrefixHandler-PathBase")
suffix := req.Header.Get("X-PrefixHandler-PathSuffix")
if ui.closureHandler == nil {
log.Printf("%v not served: handler is nil", suffix)
http.NotFound(rw, req)
return
}
if suffix == "new" {
// Add a trailing slash.
http.Redirect(rw, req, base + "new/", http.StatusFound)
return
}
suffix = path.Clean(suffix)
m := closurePattern.FindStringSubmatch(suffix)