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 (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
@ -106,6 +107,10 @@ func search(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ParseURI(uri string) (*url.URL, error) {
|
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://") {
|
if !strings.HasPrefix(uri, "http://") && !strings.HasPrefix(uri, "https://") {
|
||||||
uri = "https://" + uri
|
uri = "https://" + uri
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user