From 554af81c014ffca9c8e7f6a0e8f139eecac28cef Mon Sep 17 00:00:00 2001 From: Tom Andrade Date: Mon, 29 Apr 2019 21:33:10 +0200 Subject: [PATCH] Default to https for empty scheme URLs --- main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 9271b18..0a6500b 100644 --- a/main.go +++ b/main.go @@ -76,8 +76,11 @@ func redirect(w http.ResponseWriter, r *http.Request) { rgx, _ := regexp.Compile("[a-zA-Z0-9]+") key = rgx.FindString(key) key, status := get(key) - u, _ := url.Parse(key) if status { + u, _ := url.Parse(key) + if u.Scheme == "" { + u.Scheme = "https" + } http.Redirect(w, r, u.String(), http.StatusFound) } else { w.WriteHeader(http.StatusNotFound)