INNER CODE UNIT · Python

parse_domains

blokadaorg/blokada · scripts/convert-domains-to-rules.py:39

def parse_domains(content):
    """Parse domains from wildcard format, removing comments and wildcards."""
    domains = []

    for line in content.splitlines():
        line = line.strip()
        # Skip comments, empty lines, and other non-domain lines
        if line.startswith('#') or line.startswith('!') or not line:
            continue

        # Handle different formats
        if line.startswith('*.'):
            # Wildcard format: *.domain.com -> domain.com
            domain = line[2:]
            domains.append(domain)
        elif line.startswith('||') and line.endswith('^'):
            # ABP format: ||domain.com^ -> domain.com
            domain = line[2:-1]

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…