# dnsDomainIs()

Source: https://findproxyforurl.net/functions/dnsdomainis/ · last updated 2026-10-11

`dnsDomainIs(host, domain)` → boolean

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

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

```js
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](https://findproxyforurl.net/check/) and pick the Windows (WinHTTP) profile to see the Windows answer.


## Engine notes

- chromium: Plain suffix comparison (host.length >= domain.length && host ends with domain). (source: 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. (source: lab, verified 2026-10-11)
