aboutsummaryrefslogtreecommitdiff
path: root/url.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--url.go15
1 files changed, 15 insertions, 0 deletions
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)