@adguard/agtree
Version:
Tool set for working with adblock filter lists
41 lines (40 loc) • 1.52 kB
TypeScript
/**
* @file Converter for request header removal rules.
*/
import { type AnyRule } from '../../nodes/index.js';
import { type NodeConversionResult } from '../base-interfaces/conversion-result.js';
import { RuleConverterBase } from '../base-interfaces/rule-converter-base.js';
export declare const ERROR_MESSAGES: {
EMPTY_PARAMETER: string;
EXPECTED_END_OF_RULE: string;
MULTIPLE_DOMAINS_NOT_SUPPORTED: string;
};
/**
* Converter for request header removal rules.
*
* @todo Implement `convertToUbo` (ABP currently doesn't support header removal rules).
*/
export declare class HeaderRemovalRuleConverter extends RuleConverterBase {
/**
* Converts a header removal rule to AdGuard syntax, if possible.
*
* @param rule Rule node to convert.
*
* @returns An object which follows the {@link NodeConversionResult} interface. Its `result` property contains
* the array of converted rule nodes, and its `isConverted` flag indicates whether the original rule was converted.
* If the rule was not converted, the result array will contain the original node with the same object reference.
*
* @throws If the rule is invalid or cannot be converted.
*
* @example
* If the input rule is:
* ```adblock
* example.com##^responseheader(header-name)
* ```
* The output will be:
* ```adblock
* ||example.com^$removeheader=header-name
* ```
*/
static convertToAdg(rule: AnyRule): NodeConversionResult<AnyRule>;
}