# Case-sensitive host comparisons without lower-casing host

Source: https://findproxyforurl.net/rules/host-not-lowercased/ · last updated 2026-10-15

Rule PAC-K009 (`host-not-lowercased`), severity low, category: Compatibility across engines.

Chrome, Edge and Firefox lower-case the hostname before calling the PAC. On Windows, programs that use WinHTTP (system services, BITS) pass it as typed, while WinINet, .NET and Java programs lower-case it. Lower-casing host once at the top of the function makes the file behave the same everywhere.

## Why it matters

DNS names are case-insensitive, string comparisons in JavaScript are not. Where the engine
normalises `host` to lower case the extra call is a no-op; where it does not, a user typing
`HTTPS://Intranet.Corp.Example` misses every lower-case rule and takes the default route.
One line, `host = host.toLowerCase();`, removes the dependency on engine behaviour. The
literals must be lower case as well (PAC-C018).


## How to fix

Add host = host.toLowerCase(); as the first statement of FindProxyForURL and keep all literals lower case.

## Bad

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

## Good

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

## Engine behaviour

- chromium: The host is passed lower-cased (Case-Http.Example.COM arrives as case-http.example.com, FD00::A1 as fd00::a1). The host part of url is lower-cased too; the path keeps its case. In the source, services/proxy_resolver/proxy_resolver_v8.cc passes the canonical URL's HostNoBrackets(). (source: lab, verified 2026-10-15)
- firefox: The host is passed lower-cased (Case-Http.Example.COM arrives as case-http.example.com, FD00::A1 as fd00::a1), and so is the host part of url. In the source, netwerk/base/nsPACMan.cpp takes the normalised URI's GetAsciiHost(). (source: lab, verified 2026-10-15)
- pacparser: Passes host as given to pactester; case-sensitive comparison. (source: lab, verified 2026-05-20)
- winhttp: The host is passed with the case the program used (Example.COM stays Example.COM); BITS showed the same. An IPv6 host arrives in brackets with its case kept. (source: lab, verified 2026-10-11)
- wininet: Programs using WinINet, .NET Framework, .NET 8 and Java passed the host lower-cased, and the host part of url too; the path keeps its case. An IPv6 address keeps its letters ([FD00::A1] stays [FD00::A1]). (source: lab, verified 2026-10-15)
