Files
old-kiviscraplib/utils/utils.go

21 lines
346 B
Go
Raw Normal View History

2020-03-16 22:24:37 +01:00
package utils
import (
"net/url"
)
// IsValidUrl tests a string to determine if it is a well-structured url or not.
func IsValidUrl(toTest string) bool {
_, err := url.ParseRequestURI(toTest)
if err != nil {
return false
}
u, err := url.Parse(toTest)
if err != nil || u.Scheme == "" || u.Host == "" {
return false
}
return true
}