summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Karékinian <greg@karekinian.com>2018-12-13 16:42:38 +0100
committertechknowlogick <hello@techknowlogick.com>2018-12-13 10:42:38 -0500
commit200b974e198f5a18bf8b6638e1f8f21de17602fb (patch)
tree2e944ab3db554da0c175c1125d6eadbb6c2e2b74
parent800271ee1fd1360a24199a4f597541fdd4c1f114 (diff)
downloadgitea-200b974e198f5a18bf8b6638e1f8f21de17602fb.tar.gz
gitea-200b974e198f5a18bf8b6638e1f8f21de17602fb.zip
Backport #5537 Remove a double slash in the HTTPS redirect with Let's Encrypt (#5539)
Before: $ curl 0.0.0.0:3001 <a href="https://gitea.example.com:3000//">Found</a>. After: $ curl 0.0.0.0:3001 <a href="https://gitea.example.com:3000/">Found</a>. Fixes #5536
-rw-r--r--cmd/web.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/cmd/web.go b/cmd/web.go
index b6c014a2e3..8fed559ff5 100644
--- a/cmd/web.go
+++ b/cmd/web.go
@@ -102,7 +102,10 @@ func runLetsEncryptFallbackHandler(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Use HTTPS", http.StatusBadRequest)
return
}
- target := setting.AppURL + r.URL.RequestURI()
+ // Remove the trailing slash at the end of setting.AppURL, the request
+ // URI always contains a leading slash, which would result in a double
+ // slash
+ target := strings.TrimRight(setting.AppURL, "/") + r.URL.RequestURI()
http.Redirect(w, r, target, http.StatusFound)
}