diff --git a/website/camweb.go b/website/camweb.go index a0e36a90e..62b703f26 100644 --- a/website/camweb.go +++ b/website/camweb.go @@ -250,7 +250,7 @@ func mainHandler(rw http.ResponseWriter, req *http.Request) { } func docHandler(rw http.ResponseWriter, req *http.Request) { - findAndServeFile(rw, req, filepath.Join(filepath.Dir(*root), "doc")) + findAndServeFile(rw, req, filepath.Dir(*root)) } // modtime is the modification time of the resource to be served, or IsZero(). @@ -307,7 +307,7 @@ func findAndServeFile(rw http.ResponseWriter, req *http.Request, root string) { // the URL with a trailing slash so relative links within that // directory work. if fi.IsDir() && !strings.HasSuffix(req.URL.Path, "/") { - http.Redirect(rw, req, "/doc"+req.URL.Path+"/", http.StatusFound) + http.Redirect(rw, req, req.URL.Path+"/", http.StatusFound) return } @@ -770,7 +770,7 @@ func main() { mux.Handle("/lists", redirTo("/community")) mux.HandleFunc("/contributors", contribHandler()) - mux.Handle("/doc/", http.StripPrefix("/doc", http.HandlerFunc(docHandler))) + mux.HandleFunc("/doc/", docHandler) mux.HandleFunc("/", mainHandler) if buildbotHost != "" && buildbotBackend != "" { diff --git a/website/camweb_test.go b/website/camweb_test.go index 5bbc1a199..f596bfb8f 100644 --- a/website/camweb_test.go +++ b/website/camweb_test.go @@ -30,6 +30,7 @@ func TestRedirect(t *testing.T) { {"/gw/502aff1fd522c454e39a3723b596aca43d206d4e", "https://camlistore.googlesource.com/camlistore/+/502aff1fd522c454e39a3723b596aca43d206d4e"}, {"/gw/doc", "https://camlistore.googlesource.com/camlistore/+/master/doc"}, {"/code/?p=camlistore.git;a=commit;h=b0d2a8f0e5f27bbfc025a96ec3c7896b42d198ed", "https://camlistore.googlesource.com/camlistore/+/b0d2a8f0e5f27bbfc025a96ec3c7896b42d198ed"}, + {"/docs/schema/", "/doc/schema/"}, } for _, tt := range tests { u, err := url.ParseRequestURI(tt.in)