Utility class for working with filtering rules. Uses AGTree for robust parsing and validation.
adblockRuleToString(ruleProps: IAdblockRule): string
Converts an AdblockRule back to string representation.
containsNonAsciiCharacters(ruleText: string): boolean
Checks if the rule contains non-ASCII characters.
convertNonAsciiToPunycode(line: string): string
Converts non-ASCII domain names to Punycode.
detectSyntax(ruleText: string): string
Get the syntax type of a rule (AdGuard, uBlock Origin, ABP, Common).
extractHostname(pattern: string): string | null
Extracts hostname from an adblock rule pattern using AGTree.
findModifier(ruleProps: IAdblockRule,name: string,): IRuleModifier | null
Finds a modifier by name in the rule's options.
isAllowRule(ruleText: string): boolean
Checks if the rule is an allowing/exception rule using AGTree.
isComment(ruleText: string): boolean
Checks if the rule is a comment using AGTree.
isCosmeticRule(ruleText: string): boolean
Check if a rule is a cosmetic rule.
isEmpty(ruleText: string): boolean
Check if a rule is empty or whitespace only.
isEtcHostsRule(ruleText: string): boolean
Checks if the rule is a /etc/hosts format rule using AGTree.
isJustDomain(ruleText: string): boolean
Checks if the rule is just a domain name.
isNetworkRule(ruleText: string): boolean
Check if a rule is a network rule.
isValidRule(ruleText: string): boolean
Check if a rule is valid (parseable without errors).
loadAdblockRuleProperties(ruleText: string): IAdblockRule
Parses an adblock-style rule using AGTree.
loadEtcHostsRuleProperties(ruleText: string): IEtcHostsRule
Parses a /etc/hosts rule using AGTree.
parseRuleTokens(ruleText: string): IAdblockRuleTokens
Parses a rule text into tokens using AGTree.
parseToAST(ruleText: string): AnyRule | null
Parse a rule and return the AST node.
removeModifier(ruleProps: IAdblockRule,name: string,): boolean
Removes a modifier by name from the rule's options.