aboutsummaryrefslogtreecommitdiff
path: root/router.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--router.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/router.go b/router.go
index ed0e9b5..bfbba66 100644
--- a/router.go
+++ b/router.go
@@ -85,9 +85,21 @@ func (router *http_router_t) ServeHTTP(w http.ResponseWriter, r *http.Request) {
params["rest"] = strings.Join(segments[separator_index+4:], "/")
handle_repo_raw(w, r, params)
case "log":
+ if non_empty_last_segments_len != separator_index+5 {
+ fmt.Fprintln(w, "Too many parameters")
+ return
+ }
+ if dir_mode {
+ http.Redirect(w, r, strings.TrimSuffix(r.URL.Path, "/"), http.StatusSeeOther)
+ return
+ }
params["ref"] = segments[separator_index+4]
handle_repo_log(w, r, params)
case "commit":
+ if dir_mode {
+ http.Redirect(w, r, strings.TrimSuffix(r.URL.Path, "/"), http.StatusSeeOther)
+ return
+ }
params["commit_id"] = segments[separator_index+4]
handle_repo_commit(w, r, params)
}