Class: CombinedMatcher

matcher.CombinedMatcher()

Combines a matcher for blocking and exception rules, automatically sorts rules into two Matcher instances.

Constructor

new CombinedMatcher()

Source:

Members

(private) _allowing :module:matcher.Matcher

Matcher for exception rules.

Type:
Source:

(private) _blocking :module:matcher.Matcher

Matcher for blocking rules.

Type:
Source:

(private) _resultCache :module:caching.Cache.<string, ?(module:filterClasses.URLFilter|MatcherSearchResults)>

Lookup table of previous match results

Type:
Source:

Methods

add(filter)

Parameters:
Name Type Description
filter module:filterClasses.Filter
Source:
See:

clear()

Source:
See:

(protected) findKeyword(filter) → {string}

Parameters:
Name Type Description
filter module:filterClasses.Filter
Source:
See:
Returns:

keyword

Type
string

has(filter) → {boolean}

Parameters:
Name Type Description
filter module:filterClasses.Filter
Source:
See:
Returns:
Type
boolean

isAllowlisted() → {boolean}

Tests whether the URL is allowlisted

Source:
See:
Returns:
Type
boolean

match(url, typeMask, docDomainopt, nullable, sitekeyopt, nullable, specificOnlyopt, exhaustiveSearchopt) → (nullable) {module:filterClasses.URLFilter}

Tests whether the URL matches any of the known filters

If both a blocking and an allowing filter matches, the allowing filter is prioritized.

If only an allowing filter matches, then the allowing filter will not be returned unless it is one of the ALLOWING_TYPES used for exception rules only, or if exhaustiveSearch is true. In other words, the allowing filter is only returned if it is expected to change blocking behaviour.

Parameters:
Name Type Attributes Default Description
url URL | module:url~URLInfo | string

URL to be tested

typeMask number

bitmask of content / request types to match

docDomain string <optional>
<nullable>

domain name of the document that loads the URL

sitekey string <optional>
<nullable>

public key provided by the document

specificOnly boolean <optional>

should be true if generic matches should be ignored

exhaustiveSearch boolean <optional>
false

should return a matched allowing filter, even if the filter will have no effect on blocking behaviour

Source:
Returns:

matching filter or null

Type
module:filterClasses.URLFilter

matchesAny()

Deprecated:
  • Yes
Source:
See:

remove(filter)

Parameters:
Name Type Description
filter module:filterClasses.Filter
Source:
See:

Searches all blocking and allowing filters and returns results matching the given parameters.

Parameters:
Name Type Attributes Default Description
url URL | module:url~URLInfo | string
typeMask number
docDomain string <optional>
<nullable>
sitekey string <optional>
<nullable>
specificOnly boolean <optional>
filterType string <optional>
all

The types of filters to look for. This can be "blocking", "allowing", or "all" (default).

Source:
Returns:
Type
MatcherSearchResults