diff options
author | Runxi Yu <me@runxiyu.org> | 2025-02-11 12:43:36 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-02-11 12:43:36 +0800 |
commit | 0ef4deb35d59aa0df54dfbc886503ec2c14bfadd (patch) | |
tree | 12418820e3ceaef5a0274e579387bda11cf92b13 /handle_repo_tree.go | |
parent | repo_tree: Add link to raw (diff) | |
download | forge-0ef4deb35d59aa0df54dfbc886503ec2c14bfadd.tar.gz forge-0ef4deb35d59aa0df54dfbc886503ec2c14bfadd.tar.zst forge-0ef4deb35d59aa0df54dfbc886503ec2c14bfadd.zip |
repo_{raw,tree}: Redirect if visiting file but path_spec ends with slash
Diffstat (limited to 'handle_repo_tree.go')
-rw-r--r-- | handle_repo_tree.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/handle_repo_tree.go b/handle_repo_tree.go index 7a99692..1ef7179 100644 --- a/handle_repo_tree.go +++ b/handle_repo_tree.go @@ -53,6 +53,10 @@ func handle_repo_tree(w http.ResponseWriter, r *http.Request) { _, _ = w.Write([]byte("Error retrieving path: " + err.Error())) return } + if len(raw_path_spec) != 0 && raw_path_spec[len(raw_path_spec)-1] == '/' { + http.Redirect(w, r, "../" + path_spec, http.StatusSeeOther) + return + } file_contents, err := file.Contents() if err != nil { _, _ = w.Write([]byte("Error reading file: " + err.Error())) |