Class: Matcher

matcher.Matcher()

Blocking/allowing filter matching

Constructor

new Matcher()

Source:

Members

(private) _compiledPatternsByKeyword :Map.<string, ?module:patterns~CompiledPatterns>

Lookup table of compiled patterns for simple filters by their associated keyword

Type:
Source:

(private) _complexFiltersByKeyword :Map.<string, (module:filterClasses.URLFilter|Array.<module:filterClasses.URLFilter>)>

Lookup table for complex filters by their associated keyword

Type:
Source:

(private) _filterDomainMapsByKeyword :Map.<string, Map.<string, (module:filterClasses.URLFilter|Map.<module:filterClasses.URLFilter, boolean>)>>

Lookup table of domain maps for complex filters by their associated keyword

Type:
Source:

(private) _filterMapsByType :Map.<string, Map.<string, (module:filterClasses.URLFilter|Array.<module:filterClasses.URLFilter>)>>

Lookup table of type-specific lookup tables for complex filters by their associated keyword

Type:
Source:

(private) _keywordByFilter :Map.<module:filterClasses.URLFilter, string>

Lookup table for keywords by their associated filter

Type:
Source:

(private) _keywordlessCompiledPatterns :module:patterns~CompiledPatterns|boolean

Compiled patterns for generic complex filters with no associated keyword.

Type:
Source:

(private) _simpleFiltersByKeyword :Map.<string, (module:filterClasses.URLFilter|Array.<module:filterClasses.URLFilter>)>

Lookup table for simple filters by their associated keyword

Type:
Source:

Methods

add(filter)

Adds a filter to the matcher

Parameters:
Name Type Description
filter module:filterClasses.URLFilter
Source:

(protected) checkEntryMatch(keyword, request, typeMask, sitekeyopt, nullable, specificOnlyopt, collectionopt, nullable) → (nullable) {module:filterClasses.Filter}

Checks whether the entries for a particular keyword match a URL

Parameters:
Name Type Attributes Description
keyword string
request module:url.URLRequest
typeMask number
sitekey string <optional>
<nullable>
specificOnly boolean <optional>
collection Array.<module:filterClasses.Filter> <optional>
<nullable>

An optional list of filters to which to append any results. If specified, the function adds all matching filters to the list; if omitted, the function directly returns the first matching filter.

Source:
Returns:
Type
module:filterClasses.Filter

clear()

Removes all known filters

Source:

(protected) findKeyword(filter) → {string}

Chooses a keyword to be associated with the filter.

Because it will perform some internal optimizations, there is no guarantee that this function will always return the same result when called with the same filter.

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

keyword or an empty string if no keyword could be found

Type
string

has(filter) → {boolean}

Checks whether a filter exists in the matcher

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

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

Tests whether the URL matches any of the known filters

Parameters:
Name Type Attributes 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

Source:
Returns:

matching filter or null

Type
module:filterClasses.URLFilter

matchesAny()

Deprecated:
  • Yes
Source:
See:

remove(filter)

Removes a filter from the matcher

Parameters:
Name Type Description
filter module:filterClasses.URLFilter
Source: