mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-25 22:55:28 +00:00
31 lines
537 B
Go
31 lines
537 B
Go
package executer
|
|
|
|
import "net/url"
|
|
|
|
// isURL tests a string to determine if it is a well-structured url or not.
|
|
func isURL(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
|
|
}
|
|
|
|
// extractDomain extracts the domain name of a URL
|
|
func extractDomain(theURL string) string {
|
|
u, err := url.Parse(theURL)
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
|
|
hostname := u.Hostname()
|
|
|
|
return hostname
|
|
}
|