dnsDomainIs()

True if host ends with domain. A plain string suffix comparison, no DNS lookup.

dnsDomainIs(host, domain)  →  boolean

Used in about 45% of the real PAC files in the PAC file statistics.

Because 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

EngineBehaviourSource
chromiumPlain suffix comparison (host.length >= domain.length && host ends with domain).code, verified 2026-10-04
services/proxy_resolver/pac_js_library.h@cb6eb0e7
winhttpCase-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
Windows 11 25H2

Availability

Derived from each engine's vendored helper library plus its native bindings (see engines).
Functionchromium
<=51
chromium
>=52
firefox
all
pacparser
<=1.4.6
pacparser
>=1.5.1
winhttp
11-25H2
wininet
11-25H2
reference
all
dnsDomainIsyesyesyesyesyesyesyesyes

Related rules

Last updated: