Class: Pattern

patterns.Pattern(pattern, matchCase)

Patterns for matching against URLs.

Internally, this may be a RegExp or match directly against the pattern for simple literal patterns.

Constructor

new Pattern(pattern, matchCase)

Parameters:
Name Type Description
pattern string

pattern that requests URLs should be matched against in filter text notation

matchCase bool

true if comparisons must be case sensitive

Source:

Members

regexp :RegExp

Regular expression to be used when testing against this pattern.

null if the pattern is matched without using regular expressions.

Type:
  • RegExp
Source:

regexpSource :string

Pattern in regular expression notation. This will have a value even if regexp returns null.

Type:
  • string
Source:

Methods

hasKeywords() → {boolean}

Checks whether the pattern has keywords

Source:
Returns:
Type
boolean

isLiteralPattern() → {boolean}

Checks whether the pattern is a string of literal characters with no wildcards or any other special characters.

If the pattern is prefixed with a || or suffixed with a ^ but otherwise contains no special characters, it is still considered to be a literal pattern.

Source:
Returns:
Type
boolean

keywordCandidates() → {Array.<string>}

Finds all keywords that could be associated with this pattern

Source:
Returns:
Type
Array.<string>

matchesLocation(request) → {boolean}

Checks whether the given URL request matches this filter's pattern.

Parameters:
Name Type Description
request module:url.URLRequest

The URL request to check.

Source:
Returns:

true if the URL request matches.

Type
boolean