# URL scheme in a host pattern

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

Rule PAC-C002 (`scheme-in-host-pattern`), severity medium, category: Correctness.

host never contains "://". A pattern such as "http://intranet.corp.example" can never match it; the branch is dead code and the request takes the default route.

## Why it matters

`host` is just the hostname. A scheme prefix in the pattern makes the comparison
permanently false. This usually happens when a URL was copied from a browser address bar
into a host rule. The failure is silent: the intended exception never applies.


## How to fix

Remove the scheme (shExpMatch(host, "intranet.corp.example")) or match the URL explicitly (shExpMatch(url, "http://intranet.corp.example/*")).

## Bad

```js
function FindProxyForURL(url, host) {
  if (shExpMatch(host, "http://intranet.corp.example")) {
    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";
}
```
