From f2298e3d923d974625ea187f615be3a3ea8f243b Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sat, 15 Feb 2025 09:59:57 +0800 Subject: http_server.go: Redirect tree to tree/, same for raw --- http_server.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/http_server.go b/http_server.go index 355ac9c..346ace3 100644 --- a/http_server.go +++ b/http_server.go @@ -137,9 +137,17 @@ func (router *http_router_t) ServeHTTP(w http.ResponseWriter, r *http.Request) { handle_repo_info(w, r, params) case "tree": params["rest"] = strings.Join(segments[separator_index+4:], "/") + if len(segments) < separator_index+5 { + http.Redirect(w, r, r.URL.Path+"/", http.StatusSeeOther) + return + } handle_repo_tree(w, r, params) case "raw": params["rest"] = strings.Join(segments[separator_index+4:], "/") + if len(segments) < separator_index+5 { + http.Redirect(w, r, r.URL.Path+"/", http.StatusSeeOther) + return + } handle_repo_raw(w, r, params) case "log": if non_empty_last_segments_len > separator_index+4 { -- cgit v1.2.3