dont parse strings without tld as uri

This commit is contained in:
Timon Ringwald 2022-05-08 18:19:41 +02:00
parent e9e6f9b2a8
commit 35867a5a63

View File

@ -2,6 +2,7 @@ package main
import (
"embed"
"errors"
"flag"
"fmt"
"html/template"
@ -106,6 +107,10 @@ func search(w http.ResponseWriter, r *http.Request) {
}
func ParseURI(uri string) (*url.URL, error) {
if !strings.ContainsRune(uri, '.') {
return nil, errors.New("no top level domain")
}
if !strings.HasPrefix(uri, "http://") && !strings.HasPrefix(uri, "https://") {
uri = "https://" + uri
}