filter

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 3, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package filter provides URL filtering based on domains and patterns.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Domains       []string // Domains to ignore (includes subdomains)
	GlobPatterns  []string // Glob patterns (e.g., "*.local/*")
	RegexPatterns []string // Regex patterns (e.g., ".*\\.internal\\..*")
}

Config holds filter configuration.

type Filter

type Filter struct {
	// contains filtered or unexported fields
}

Filter determines which URLs should be skipped during link checking.

func New

func New(cfg Config) (*Filter, error)

New creates a new Filter from the given configuration. Patterns are compiled once for performance. Returns an error if any pattern fails to compile.

func (*Filter) HasRules

func (f *Filter) HasRules() bool

HasRules returns true if the filter has any rules defined.

func (*Filter) IgnoredCount

func (f *Filter) IgnoredCount() int

IgnoredCount returns the number of URLs that were ignored.

func (*Filter) IgnoredURLs

func (f *Filter) IgnoredURLs() []IgnoreReason

IgnoredURLs returns all ignored URLs with their reasons.

func (*Filter) Reset

func (f *Filter) Reset()

Reset clears the list of ignored URLs. Useful if reusing a filter for multiple checks.

func (*Filter) ShouldIgnore

func (f *Filter) ShouldIgnore(rawURL, file string, line int) bool

ShouldIgnore checks if a URL should be skipped. If the URL matches any rule, it records the reason and returns true. Check order (fastest first): domain → glob → regex.

func (*Filter) Stats

func (f *Filter) Stats() (domains, globs, regexes int)

Stats returns a summary of the filter's rules.

type IgnoreReason

type IgnoreReason struct {
	Type string // "domain", "pattern", or "regex"
	Rule string // The rule that matched
	URL  string // The URL that was ignored
	File string // Source file
	Line int    // Line number
}

IgnoreReason describes why a URL was ignored.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL