diff options
author | Runxi Yu <me@runxiyu.org> | 2025-02-15 09:59:57 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-02-15 09:59:57 +0800 |
commit | f2298e3d923d974625ea187f615be3a3ea8f243b (patch) | |
tree | d5a8780cd00af7d1d568f62643825920bf9abba0 | |
parent | style.css: break-word for #readme (diff) | |
download | forge-f2298e3d923d974625ea187f615be3a3ea8f243b.tar.gz forge-f2298e3d923d974625ea187f615be3a3ea8f243b.tar.zst forge-f2298e3d923d974625ea187f615be3a3ea8f243b.zip |
http_server.go: Redirect tree to tree/, same for raw
-rw-r--r-- | http_server.go | 8 |
1 files changed, 8 insertions, 0 deletions
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 { |