From fa62d8eae273d89937d65d6a294f028e1ce22d88 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Thu, 6 Mar 2025 22:01:08 +0800 Subject: group/index: Allow repo creation via web --- url.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'url.go') diff --git a/url.go b/url.go index 8be7047..393913f 100644 --- a/url.go +++ b/url.go @@ -99,6 +99,21 @@ func redirect_without_slash(w http.ResponseWriter, r *http.Request) bool { return false } +func redirect_unconditionally(w http.ResponseWriter, r *http.Request) { + request_uri := r.RequestURI + + path_end := strings.IndexAny(request_uri, "?#") + var path, rest string + if path_end == -1 { + path = request_uri + } else { + path = request_uri[:path_end] + rest = request_uri[path_end:] + } + + http.Redirect(w, r, path+rest, http.StatusSeeOther) +} + func path_escape_cat_segments(segments []string) string { for i, segment := range segments { segments[i] = url.PathEscape(segment) -- cgit v1.2.3