prefixfilter

package
v1.43.1 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendReplace

func AppendReplace(dst []byte, srcFilter, dstFilter, s string) []byte

AppendReplace replaces srcFilter prefix with dstFilter prefix at s, appends the result to dst and returns it.

func IsWildcardFilter

func IsWildcardFilter(filter string) bool

IsWildcardFilter returns true if the filter ends with '*', e.g. it matches any string containing the prefix in front of '*'.

func MatchAll

func MatchAll(filters []string) bool

MatchAll returns true if filters match any string

func MatchFilter

func MatchFilter(filter, s string) bool

MatchFilter returns true if s matches filter.

func MatchFilters

func MatchFilters(filters []string, s string) bool

MatchFilters returns true if s matches any filter from filters.

Types

type Filter

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

Filter allow filtering by full strings and by prefixes ending with '*'.

func (*Filter) AddAllowFilter

func (f *Filter) AddAllowFilter(filter string)

AddAllowFilter adds the given filter to allowlist at f.

The filter may end with '*'. In this case it matches all the strings starting with the prefix before '*'.

func (*Filter) AddAllowFilters

func (f *Filter) AddAllowFilters(filters []string)

AddAllowFilters adds the given filters to allowlist at f.

Every filter may end with '*'. In this case it matches all the strings starting with the prefix before '*'.

func (*Filter) AddDenyFilter

func (f *Filter) AddDenyFilter(filter string)

AddDenyFilter adds the the given filter to denylist at f.

Every filter may end with '*'. In this case it stops matching all the strings starting with the prefix before '*'.

func (*Filter) AddDenyFilters

func (f *Filter) AddDenyFilters(filters []string)

AddDenyFilters adds the given filters to denylist at f.

Every filter may end with '*'. In this case it stops matching all the strings starting with the prefix before '*'.

func (*Filter) Clone

func (f *Filter) Clone() *Filter

Clone returns a copy of f.

func (*Filter) GetAllowFilters

func (f *Filter) GetAllowFilters() []string

GetAllowFilters returns allow filters from f.

func (*Filter) GetAllowStrings

func (f *Filter) GetAllowStrings() ([]string, bool)

GetAllowStrings returns the list of allow strings if there are no wildcard filters in the allow list

It returns false if there are wildcard filters

func (*Filter) GetDenyFilters

func (f *Filter) GetDenyFilters() []string

GetDenyFilters returns deny filters from f.

func (*Filter) MatchAll

func (f *Filter) MatchAll() bool

MatchAll returns true if f matches any string.

func (*Filter) MatchNothing

func (f *Filter) MatchNothing() bool

MatchNothing returns true if f doesn't match anything.

func (*Filter) MatchString

func (f *Filter) MatchString(s string) bool

MatchString returns true if s matches f.

func (*Filter) MatchStringOrWildcard

func (f *Filter) MatchStringOrWildcard(s string) bool

MatchStringOrWildcard returns true if s matches f.

s may be either a regular string or a wildcard ending with '*'. If s is a wildcard, then true is returned if at least a single string matching this wildcard matches f.

func (*Filter) Reset

func (f *Filter) Reset()

Reset resets f to the initial zero state.

func (*Filter) String

func (f *Filter) String() string

String returns human-readable representation of f.

Jump to

Keyboard shortcuts

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