Add http protocol scheme if it's not exist

This commit is contained in:
Mikhail Klementyev 2016-07-25 17:50:30 +03:00
parent d4a5ae0b1b
commit 80f2414c1e

View File

@ -93,6 +93,10 @@ func parseLinks(db *sql.DB, body []byte, req *http.Request) (htmlPage string, er
func cmd_url(db *sql.DB, url string) { func cmd_url(db *sql.DB, url string) {
client := &http.Client{} client := &http.Client{}
if !strings.Contains(url, "://") {
url = "http://" + url
}
// TODO Full url encoding // TODO Full url encoding
req, err := http.NewRequest("GET", strings.Replace(url, " ", "%20", -1), nil) req, err := http.NewRequest("GET", strings.Replace(url, " ", "%20", -1), nil)
if err != nil { if err != nil {