# Upper-case letters in a hostname pattern

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

Rule PAC-C018 (`uppercase-pattern-literal`), severity medium, category: Correctness, top 20 #20.

Browsers hand the PAC a lower-cased hostname, so a pattern such as "Intranet.Corp.Example" never matches in Chromium or Firefox. Where the host keeps its case (Windows programs using WinHTTP, such as BITS), comparisons are case-sensitive, so write patterns in lower case and lower-case host.

## Why it matters

URL parsing in Chromium and Firefox follows the URL Standard, which lower-cases ASCII
domain names, so `host` arrives lower-cased and the pattern must be lower-case to match
(measured in Chrome, Edge and Firefox, lab 2026-10-15).
On Windows, programs that use WinHTTP (system services, BITS) pass the hostname with the case
the program used, while WinINet, .NET and Java programs lower-case it (lab, 2026-10-11). In the
WinHTTP case the same upper-case pattern matches only if the name was written that way, and
`dnsDomainIs` and `shExpMatch` compare case-sensitively there. The robust idiom is to lower-case both sides:
`host = host.toLowerCase();` at the top of the function and lower-case literals everywhere
(PAC-K009). Mixed-case literals are therefore always wrong.


## How to fix

Write all hostname literals in lower case and add host = host.toLowerCase(); at the start of the function.

## 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; dnsDomainIs(host, ".example.com") does not match "Example.com". (source: lab, verified 2026-05-20)
- winhttp: host keeps its case (Example.COM arrives as Example.COM, also from BITS). dnsDomainIs and shExpMatch compare case-sensitively; localHostOrDomainIs ignores case. (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)
