shExpMatch()

Shell-glob match of str against pattern; * matches any sequence, ? one character. The whole string must match.

shExpMatch(str, pattern)  →  boolean

The helper libraries convert the glob into a regular expression. * also matches dots, so shExpMatch(host, "*example.com") matches notexample.com; use "*.example.com". Matching on url instead of host lets a query string such as ?r=example.com trigger the rule.

Example

if (shExpMatch(host, "*.example.com") || host == "example.com") {
  return "DIRECT";
}

Engine notes

EngineBehaviourSource
chromiumConverts the glob to a RegExp escaping only '.', so ( ) | keep their regex meaning.code, verified 2026-10-04
services/proxy_resolver/pac_js_library.h@cb6eb0e7
firefoxSame conversion as Chromium (escapes '.', maps * and ?).code, verified 2026-10-04
netwerk/base/ascii_pac_utils.js@3f73c528

Availability

Derived from each engine's vendored helper library plus its native bindings (see engines).
Functionchromium
<=51
chromium
>=52
firefox
all
pacparser
<=1.4.6
pacparser
1.5.0
pacparser
>=1.5.1
reference
all
shExpMatchyesyesyesyesyesyesyes

Related rules