Documentation
¶
Overview ¶
SPDX-License-Identifier: MIT
Package urlverifier is a Go library for URL validation and verification: does this URL actually work? SPDX-License-Identifier: MIT
Index ¶
- type HTTP
- type Result
- type Verifier
- func (v *Verifier) AllowHTTPCheckInternal()
- func (v *Verifier) CheckHTTP(urlToCheck string) (*HTTP, error)
- func (v *Verifier) DisableHTTPCheck()
- func (v *Verifier) DisallowHTTPCheckInternal()
- func (v *Verifier) EnableHTTPCheck()
- func (v *Verifier) IsRequestURI(rawURL string) bool
- func (v *Verifier) IsRequestURL(rawURL string) bool
- func (v *Verifier) Verify(rawURL string) (*Result, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTP ¶
type HTTP struct { Reachable bool `json:"reachable"` // Whether the URL is reachable via HTTP. This may be true even if the response is an HTTP error e.g. a 500 error. StatusCode int `json:"status_code"` // The HTTP status code IsSuccess bool `josn:"is_success"` // Whether the HTTP response is a success (2xx) or success-like code (3xx) }
HTTP is the result of a HTTP check
type Result ¶
type Result struct { URL string `json:"url"` // The URL that was checked URLComponents *url.URL `json:"url_components"` // The URL components, if the URL is valid IsURL bool `json:"is_url"` // Whether the URL is valid IsRFC3986URL bool `json:"is_rfc3986_url"` // Whether the URL is a valid URL according to RFC 3986. This is the same as IsRFC3986URI but with a check for a scheme. IsRFC3986URI bool `json:"is_rfc3986_uri"` // Whether the URL is a valid URI according to RFC 3986 HTTP *HTTP `json:"http"` // The result of a HTTP check, if enabled }
Result is the result of a URL verification
type Verifier ¶
type Verifier struct {
// contains filtered or unexported fields
}
Verifier is a URL Verifier. Create one using NewVerifier()
func (*Verifier) AllowHTTPCheckInternal ¶ added in v0.2.0
func (v *Verifier) AllowHTTPCheckInternal()
AllowHTTPCheckInternal allows checking internal URLs
func (*Verifier) DisableHTTPCheck ¶
func (v *Verifier) DisableHTTPCheck()
DisableHTTPCheck disables checking if the URL is reachable via HTTP
func (*Verifier) DisallowHTTPCheckInternal ¶ added in v0.2.0
func (v *Verifier) DisallowHTTPCheckInternal()
DisallowHTTPCheckInternal disallows checking internal URLs
func (*Verifier) EnableHTTPCheck ¶
func (v *Verifier) EnableHTTPCheck()
EnableHTTPCheck enables checking if the URL is reachable via HTTP
func (*Verifier) IsRequestURI ¶
IsRequestURI checks if the string rawURL, assuming it was received in an HTTP request, is an absolute URI or an absolute path. Implemented from govalidator: https://github.com/asaskevich/govalidator/blob/f21760c49a8d602d863493de796926d2a5c1138d/validator.go#L144
func (*Verifier) IsRequestURL ¶
IsRequestURL checks if the string rawURL, assuming it was received in an HTTP request, is a valid URL confirm to RFC 3986. Implemented from govalidator: https://github.com/asaskevich/govalidator/blob/f21760c49a8d602d863493de796926d2a5c1138d/validator.go#L130