Default to https for empty scheme URLs

This commit is contained in:
Tom Andrade 2019-04-29 21:33:10 +02:00
parent c61ddfbc79
commit 554af81c01
Signed by: wolvie
GPG Key ID: 31AAB07872E82669

View File

@ -76,8 +76,11 @@ func redirect(w http.ResponseWriter, r *http.Request) {
rgx, _ := regexp.Compile("[a-zA-Z0-9]+") rgx, _ := regexp.Compile("[a-zA-Z0-9]+")
key = rgx.FindString(key) key = rgx.FindString(key)
key, status := get(key) key, status := get(key)
u, _ := url.Parse(key)
if status { if status {
u, _ := url.Parse(key)
if u.Scheme == "" {
u.Scheme = "https"
}
http.Redirect(w, r, u.String(), http.StatusFound) http.Redirect(w, r, u.String(), http.StatusFound)
} else { } else {
w.WriteHeader(http.StatusNotFound) w.WriteHeader(http.StatusNotFound)