All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.developerdan.blocklist.tools.DomainListParser Maven / Gradle / Ivy

There is a newer version: 1.2.1
Show newest version
package com.developerdan.blocklist.tools;

import java.util.Optional;
import java.util.regex.Pattern;

public final class DomainListParser extends BlocklistParser {

    private static final Pattern STRIP_HOSTS_COMMENTS = Pattern.compile("^([^#]+)", Pattern.UNICODE_CASE | Pattern.CASE_INSENSITIVE);

    @Override
    public Optional parseLine(String line) {
        var matcher = DomainListParser.STRIP_HOSTS_COMMENTS.matcher(line);
        if (matcher.find()) {
            return Domain.fromString(matcher.group(0).strip());
        }
        return Optional.empty();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy