Check redirect path and add trailing slash if necessary
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details

This commit is contained in:
Tyler 2022-03-31 22:23:51 -04:00
parent aa8a187bda
commit b4ed1fc1a3
1 changed files with 5 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import (
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
"strings"
) )
func statusHandler(w http.ResponseWriter, r *http.Request) { func statusHandler(w http.ResponseWriter, r *http.Request) {
@ -82,6 +83,10 @@ func redirectHandler(w http.ResponseWriter, r *http.Request) {
} }
} }
if strings.HasSuffix(r.URL.Path, "/") && !strings.HasSuffix(redirectPath, "/") {
redirectPath += "/"
}
u := &url.URL{ u := &url.URL{
Scheme: scheme, Scheme: scheme,
Host: server.Host, Host: server.Host,