dnsDomainIs()
True if host ends with domain. A plain string suffix comparison, no DNS lookup.
dnsDomainIs(host, domain) → booleanBecause it is a plain suffix test, the domain must start with a dot: dnsDomainIs(host, "corp.example")
also matches evilcorp.example. Write dnsDomainIs(host, ".corp.example") and, if the apex
itself matters, add host == "corp.example".
Example
if (dnsDomainIs(host, ".corp.example") || host == "corp.example") {
return "DIRECT";
}
On Windows an upper-case host name misses a lower-case dnsDomainIs pattern
dnsDomainIs compares case-sensitively in every engine, but the browsers lower-case the host
first, while Windows programs that use WinHTTP pass it as written. There
dnsDomainIs("www.Example.COM", ".example.com") is false. Windows also checks only the first
place where the domain occurs, so dnsDomainIs("a.foo.com.foo.com", ".foo.com") is false
there, and dnsDomainIs(host, "") is false. Start the function with
host = host.toLowerCase();. Paste your file into the PAC file tester and pick the Windows (WinHTTP) profile to see the Windows answer.Check how your own file behaves with the PAC file tester: switch the engine profile between Chromium, Firefox, pacparser and Windows and compare the trace. All engine differences are collected in pactester vs Chrome and Firefox.
Engine notes
| Engine | Behaviour | Source |
|---|---|---|
| chromium | Plain suffix comparison (host.length >= domain.length && host ends with domain). | code, verified 2026-10-04 |
| winhttp | Case-sensitive suffix test, like the browsers, but the host is not lower-cased first. Checks only the first place where the domain occurs: dnsDomainIs("a.foo.com.foo.com", ".foo.com") is false. dnsDomainIs(host, "") is false. | lab, verified 2026-10-11 |
Availability
| Function | chromium | chromium | firefox | pacparser | pacparser | winhttp | wininet | reference |
|---|---|---|---|---|---|---|---|---|
dnsDomainIs | yes | yes | yes | yes | yes | yes | yes | yes |
Related rules
- dnsDomainIs pattern without a leading dot matches look-alike domains PAC-X003
- Wildcard characters in dnsDomainIs or localHostOrDomainIs PAC-C004
- Very short or trailing-dot dnsDomainIs pattern PAC-C011
- Case-sensitive host comparisons without lower-casing host PAC-K009
- Upper-case letters in a hostname pattern PAC-C018