# Bitwise | or & used instead of || or &&

Source: https://findproxyforurl.net/rules/bitwise-or-in-condition/ · last updated 2026-10-04

Rule PAC-C006 (`bitwise-or-in-condition`), severity medium, category: Correctness.

A single | or & converts both operands to 32-bit integers. For booleans the result is accidentally right, but both sides are always evaluated and non-boolean operands produce 0, which silently drops the branch.

## Why it matters

`a | b` evaluates both sides (no short-circuit), so a DNS call on the right-hand side runs
even when the left side already decided. The operands are coerced to integers: a string
such as `shExpMatch(...) | "DIRECT"` becomes `0` and the condition is never true. `&`
behaves correspondingly. The typo survives casual testing because `true | false` is `1`,
which is truthy.


## How to fix

Replace | with || and & with &&.

## Bad

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

## Good

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