Documentation
¶
Overview ¶
Package urlcheck supplies shared, offline URL policy for config and HTML. Browser URL parsing is delegated to the pure Go WHATWG implementation.
Index ¶
- func Apply(issues []diagnostic.Diagnostic, rules map[string]diagnostic.Severity) []diagnostic.Diagnostic
- func Catalog() []diagnostic.RuleInfo
- func DecodeCSS(s string) string
- func Embedded(raw string) bool
- func LocalAsset(raw string) bool
- func LooksURL(value string) bool
- func Placeholder(raw string) bool
- func PublicURL(value string) bool
- func RefreshURL(value string) (string, int, bool)
- func Scheme(raw string) string
- func Template(t *htmltemplate.Template, files map[string][]byte, registries ...*Registry) []diagnostic.Diagnostic
- func Trustable(raw string) bool
- func URLAttribute(tag, attribute string, attrs map[string]string) (bool, bool)
- func URLHint(attribute string) string
- func VisibleURLLiterals(raw []byte) []int
- type Analyzer
- type Candidate
- type Declaration
- type Finding
- type Reference
- type Registry
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
func Apply(issues []diagnostic.Diagnostic, rules map[string]diagnostic.Severity) []diagnostic.Diagnostic
func Catalog ¶
func Catalog() []diagnostic.RuleInfo
Catalog lists the link rules that run on authoring sources before rendering. links.syntax, links.declared and links.behavior also judge final HTML and are defined once, with the final-document rules, in check.DefaultRules.
func DecodeCSS ¶
DecodeCSS decodes an already-tokenized CSS identifier/string. Token boundary validation belongs to the CSS lexer; HTML entities do not apply here.
func LocalAsset ¶
func Placeholder ¶ added in v0.1.8
Placeholder reports template markers and reserved example destinations.
func PublicURL ¶
PublicURL is a local browser-parsed public HTTP(S) reference screen. It does not resolve DNS or prove reachability. Fragments are excluded by this contract.
func RefreshURL ¶
RefreshURL extracts the destination using HTML's declarative refresh token boundaries (ASCII delay/separators, optional URL= and optional quotes). A delay-only refresh has no explicit destination to register.
func Template ¶
func Template(t *htmltemplate.Template, files map[string][]byte, registries ...*Registry) []diagnostic.Diagnostic
Template checks all parsed source branches/partials. Standard Go parse trees distinguish literal HTML from template syntax; HTML tokenizers then identify destinations. No regex scans for href= or naive splitting on template braces.
func VisibleURLLiterals ¶
VisibleURLLiterals is an advisory for duplicated URL copy. Code samples, executable/structured scripts, styles and comments are intentionally excluded.
Types ¶
type Candidate ¶
func Candidates ¶
Candidates follows HTML's URL/descriptor token boundaries, including commas inside data URLs and parenthesized descriptors. Descriptor conformance is left to a future image rule; all candidate destinations are inspected independently.
type Declaration ¶
type Declaration struct {
Path, Value string
Location diagnostic.Location
}
type Finding ¶
type Finding struct {
Severity diagnostic.Severity
Message, Hint string
}
type Reference ¶
type Reference struct {
Tag, Attribute, Value string
Offset, End int
Resource bool
Import bool // CSS @import, rather than a declaration URL.
}
func AllReferences ¶
AllReferences includes URL-like values in embedded JSON/JSON-LD in addition to URL-bearing HTML attributes. It never inspects executable JS as HTML.
func CSSReferences ¶
CSSReferences delegates token boundaries to parse/v2. String-valued @import and image-set candidates are URLs; content strings and namespace IDs are not.
func JSONReferences ¶
JSONReferences finds URL-like JSON string values. Vocabulary identifiers are intentionally excluded: @context/@type are schemas, not managed destinations. Useful for JSON-LD; malformed JSON belongs to the existing HTML JSON rule.
func References ¶
References uses HTML tokenizers, not a URL regex. Attribute values are decoded exactly once. Every offset refers to the original byte slice; lex a clone because parse/v2 normalizes attribute names in its backing buffer.
type Registry ¶
type Registry struct {
Analyzer *Analyzer
Declarations []Declaration
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry(base string, declarations []Declaration) *Registry
func (*Registry) Check ¶
func (r *Registry) Check() []diagnostic.Diagnostic
func (*Registry) Match ¶
func (r *Registry) Match(raw string) []Declaration