# FindProxyForURL does not take exactly two parameters

Source: https://findproxyforurl.net/rules/findproxyforurl-wrong-arity/ · last updated 2026-10-04

Rule PAC-E004 (`findproxyforurl-wrong-arity`), severity medium, category: Errors and robustness.

Engines call FindProxyForURL(url, host). With one parameter the hostname is unavailable; with more than two the extra parameters are always undefined.

## Why it matters

The engine always passes two arguments. A function declared with a single parameter has
no way to read the hostname unless it parses `url` itself. Extra parameters are never
filled and any logic based on them silently takes the `undefined` branch. Parameter
*names* are free (see PAC-B002); the *count* is what matters.


## How to fix

Declare the function as function FindProxyForURL(url, host).

## Bad

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

## Good

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