Documentation
¶
Overview ¶
Package urlverify provides functionality to extract and validate URLs and domains from text.
The package uses the Public Suffix List to validate domains and supports: - HTTP/HTTPS URLs - Plain domain names - IPv4 and IPv6 addresses - Dynamic DNS services (e.g., dyndns.org, no-ip.org)
Example usage:
text := "Visit https://example.com and check foo.dyndns.org"
validDomains := urlverify.ExtractAll(text)
Returns: ["https://example.com", "foo.dyndns.org"]
result := urlverify.ValidateDomain("foo.dyndns.org")
if result.Valid {
fmt.Printf("Valid domain: %s (TLD: %s)\n", "foo.dyndns.org", result.TLD)
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractAll ¶
ExtractAll extracts and validates all URLs and domains from the given text, returning them exactly as they appeared in the original text (without adding schema).
func NormalizeURI ¶ added in v1.0.3
NormalizeURI normalizes a URI by converting it to ASCII and lowercasing it. Returns the normalized URI or an error if the conversion fails.
Types ¶
type ValidationResult ¶
type ValidationResult struct {
Valid bool // Whether the URL or domain is valid
Reason string // Explanation of the validation result
Type URLType // Type of URL or domain
TLD string // The effective TLD, if applicable or an IP address
URL *url.URL // Only set if the URL was successfully parsed
}
ValidationResult represents the result of domain validation.
func ValidateDomain ¶
func ValidateDomain(raw string) ValidationResult
ValidateDomain validates a single URL or domain string and returns detailed validation result.