dont parse strings without tld as uri
This commit is contained in:
parent
e9e6f9b2a8
commit
35867a5a63
5
main.go
5
main.go
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user