# Very short or trailing-dot dnsDomainIs pattern

Source: https://findproxyforurl.net/rules/dnsdomainis-short-pattern/ · last updated 2026-10-15

Rule PAC-C011 (`dnsdomainis-short-pattern`), severity medium, category: Correctness.

Patterns like ".uk." (trailing dot) or ".ab" are suspicious. A pattern with a trailing dot matches only when the address itself was typed with a trailing dot; a two-letter suffix without a label is a TLD or a typo.

## Why it matters

Chrome, Edge, Firefox and Windows (WinHTTP and WinINet) pass `host` exactly as the address gives
it, with or without a final dot (lab, 2026-10-15). An ordinary address has no final dot, so
`dnsDomainIs(host, ".uk.")` is false for it. The reverse also holds: when someone opens
`http://intranet.corp.example./`, the script gets `intranet.corp.example.`, and both
`dnsDomainIs(host, ".corp.example")` and `shExpMatch(host, "*.corp.example")` are false, so the
request takes the default route of the file. If a rule must also catch such addresses, remove a
final dot from `host` first.

A pattern of only a few characters (`.ab`, `.x`) is either a TLD match (PAC-X005) or a
truncated domain. Both make the branch dead or far too broad.


## How to fix

Use a full domain suffix such as ".corp.example" without a trailing dot. To treat "host." like "host", start with `if (host.charAt(host.length - 1) == ".") host = host.slice(0, -1);`.

## Bad

```js
function FindProxyForURL(url, host) {
  if (dnsDomainIs(host, ".example.")) {
    return "DIRECT";
  }
  return "PROXY proxy.corp.example:8080";
}
```

## Good

```js
function FindProxyForURL(url, host) {
  if (dnsDomainIs(host, ".corp.example")) {
    return "DIRECT";
  }
  return "PROXY proxy.corp.example:8080";
}
```

## Engine behaviour

- chromium: A trailing dot in the address is kept in host and in the host part of url (http://case-dot.example.test.:8090/P arrives as host case-dot.example.test.); dnsDomainIs(host, ".example.test") is then false. In the source, url/url_canon_host.cc keeps the final dot and services/proxy_resolver/pac_js_library.h dnsDomainIs is a plain suffix comparison. (source: lab, verified 2026-10-15)
- firefox: A trailing dot is kept in host and url, as in Chromium; dnsDomainIs(host, ".example.test") is false. In the source, netwerk/base/nsPACMan.cpp takes GetAsciiHost(), which keeps the dot. (source: lab, verified 2026-10-15)
- winhttp: A trailing dot is kept in host and url; dnsDomainIs(host, ".example.test") is false. (source: lab, verified 2026-10-15)
- wininet: A trailing dot is kept in host and url, in a direct proxy query and in real requests of a WinINet program; dnsDomainIs(host, ".example.test") is false. (source: lab, verified 2026-10-15)
