Define the unit you match

DNS operates on names. A browser request also has a scheme, hostname, port, and path. RFC 1035 describes foundational DNS behavior, while the WHATWG URL Standard describes web URL parsing. These are useful reference points because manually splitting a web address at slashes or colons can confuse credentials, ports, and hostnames.

Choose hostname matching for the first version. Keep “exact host” and “host plus subdomains” as distinct rule types. A hostname does not represent an entire category of services, and a shared infrastructure domain may host unrelated activity. Category decisions need evidence about the entry, not just a suggestive word inside its name.

Use reserved names for examples. RFC 6761 describes special-use names, including the role of the .test namespace. Synthetic fixtures avoid directing anyone to a real gambling site.

Normalize once before comparing

Hostnames are case-insensitive, and DNS presentations can include a final dot. Internationalized Domain Names in Applications, known as IDNA, address non-ASCII names through a defined representation. Use a maintained parsing implementation for that conversion rather than inventing a character replacement scheme.

A normalization contract should say whether inputs are hostnames or URLs, which malformed inputs are rejected, and how a trailing dot is handled. Reject empty labels and unexpected syntax instead of quietly repairing arbitrary text. Keep ports and paths out of hostname rules. If an input can be an IP address, handle that as an explicit separate case.

Apply the same normalization to stored rules and candidate destinations. Otherwise a rule editor and an enforcement adapter can disagree while both appear to be working.

Make the suffix boundary visible

A substring search is not a domain matcher. The synthetic name notexample.test must not match a rule for example.test. Requiring the separating dot prevents that particular mistake. The following static sketch assumes valid, already-normalized hostnames; it is not a parser or an installable extension.

// Conceptual matching step after validation.
function matches(host, rule) {
  if (host === rule.host) return true;
  return rule.includeSubdomains
    && host.endsWith("." + rule.host);
}

The Public Suffix List describes boundaries such as public registration suffixes. It matters when deciding what counts as a registrable domain; “take the last two labels” is not a general solution. Do not allow a broad public suffix to become a blocking rule accidentally. Even a registrable domain can contain unrelated services, so that boundary alone does not justify a block.

Keep exceptions and provenance explicit

Give each rule a source, a reason, and a scope. A list imported from another project may have been created for advertising, malware, or parental controls rather than gambling. Reusing its format does not establish that its classification suits your purpose. Pi-hole-style domain lists and browser filter syntax also have different semantics.

Blocking entry
A normalized host with a declared match type and a recorded reason.
Exception
A narrowly scoped override with its own explanation and precedence.
Provenance
The source and version that allow a later change to be understood.

Decide whether exceptions win before generating platform rules. Preserve access to support and ordinary services using reviewed exceptions, not a universal escape rule. Avoid putting personal browsing observations into a shared list or diagnostic file.

Update without losing the known state

Parse a candidate list separately, reject invalid entries, and run your fixture set before replacing active rules. Keep a last-known-good version for recovery. An update should be applied as a coherent change, not a sequence that briefly leaves enforcement empty.

  1. Read and validate the candidate format.
  2. Normalize and deduplicate entries.
  3. Check broad rules and exception conflicts.
  4. Run expected block and allow fixtures.
  5. Activate the version and confirm adapter acceptance.

A checksum can detect accidental changes but does not prove authorship. Authenticity depends on the distribution method and trust model. Describe an unsuccessful update plainly while retaining the previous rules when that is the chosen behavior.