Module: filters/index

Classes

FilterParsingError

Members

(inner, constant) CONTENT_FILTER :RegExp

Regular expression that content filters should match

Type:
  • RegExp
Source:

(inner, constant) FILTER_OPTIONS :RegExp

Regular expression that options on a RegExp filter should match

Type:
  • RegExp
Source:

(inner, constant) INVALID_CSP :RegExp

Regular expression that matches an invalid Content Security Policy

Type:
  • RegExp
Source:

Methods

(static) normalize(text, dontSanitizenullable) → {string}

Removes unnecessary whitespaces from filter text, will only return null if the input parameter is null.

Parameters:
Name Type Attributes Description
text string
dontSanitize boolean <nullable>

avoid expensive operations on text.

Source:
Returns:
Type
string

(static) parse(text) → {ParsedFilter|FilterParsingError}

Parse the filter text representation into a structure.

This is meant to be called by {module:filterClasses.URLFilter.fromText}

Parameters:
Name Type Description
text string

the filter normalized text. Call normalize() on the text prior to this, unless it is already normalized.

Source:
Returns:

The parsed filter, or a FilterParsingError.

Type
ParsedFilter | FilterParsingError

Type Definitions

ParsedFilter

Type:
  • Object
Properties:
Name Type Attributes Description
blocking bool

Whether it's a blocking filter or not.

text string

The filter text.

regexpSource string

The source of the matching RegExp.

contentType number

The content types for the filter.

matchCase bool <nullable>

If the filter is case sensitive.

domains Array.<string> <nullable>

The domains to match ($domains option).

sitekeys Array.<string> <nullable>

The sitekeys to match.

headers object <nullable>

The headers filtering.

rewrite string <nullable>

The URL for to rewrite to.

csp string <nullable>

The CSP directive.

Source: