Last active
October 1, 2019 11:08
-
-
Save gnuns/c624adb7701d000f79b43b75b8935af3 to your computer and use it in GitHub Desktop.
Golang: IsValidURL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"net/url" | |
"golang.org/x/net/publicsuffix" | |
) | |
func IsValidURL(s string) bool { | |
u, err := url.Parse(s) | |
if err != nil { | |
return false | |
} | |
_, icann := publicsuffix.PublicSuffix(u.Hostname()) | |
return icann | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment