# Path, port or query characters in a host pattern

Source: https://findproxyforurl.net/rules/invalid-host-pattern-characters/ · last updated 2026-10-04

Rule PAC-C003 (`invalid-host-pattern-characters`), severity medium, category: Correctness.

host contains no slash, colon, question mark, space or port. A host pattern with any of these can never match.

## Why it matters

Hostnames consist of letters, digits, hyphens and dots (IP literals of digits and dots).
`shExpMatch(host, "www.corp.example/app")`, `"intranet.corp.example:8080"` or a pattern with a
trailing space is always false. The rule the author wanted silently does not exist. Port
and path decisions must be made on `url`, and even there with care (PAC-X008).


## How to fix

Strip the path/port from the host pattern, or move the check to url with a pattern anchored at scheme and path.

## Bad

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

## Good

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