PAC file condition statement when to use "localHostOrDomainIs" or "shExpMatch"?

,

Hi all, when do we use these 2 statement condition statement ?

I do realised most of the bypassing we are using

if (shExpMatch(host, “example.com”))

But recently i got to know the actual way is to use

if (shExpMatch(url, “example.com”))

But in tunnel 2.0 bypassing i was reading through the documentation (https://help.zscaler.com/z-app/best-practices-adding-bypasses-z-tunnel-2.0) for domain bypass its recommended to use

(localHostOrDomainIs(host, “”))

For localHostOrDomainIs the available options to use is only host or there can be URL too ?

By default nowadays browsers strip privacy and security sensitive parts (ie both path and query parameters) off from url, so it is - except for the port which comes in url but not host - basically ‘url=host:port’.

For bypassing URL somehow for localHostOrDomainIs(host,"") it will not work, same goes if i change it to localHostOrDomainIs(url,""). So i am wondering for localHostOrDomainIs when will we use on

You try too match against “” - which is essentially nothing.
The only time this would match is if host or url are empty.

The docu you refer to clearly shows

if (localHostOrDomainIs(host, "<domain>"))

So you need to set domain to whatever you need.

o apologise i was copy pasting the code and forgot to add in the url i am referring to as an example.

For below the two method it didnt work well…

localHostOrDomainIs(host,“example.com”) OR localHostOrDomainIs(url,“example.com”)

I presume what you wanted to convey is that localHostOrDomainIs(host,“example.com”) only works for domains instead for URL? correct me if i am wrong.

here is a description about how localHostOrDomainIs is working - https://developer.mozilla.org/en-US/docs/Web/HTTP/Proxy_servers_and_tunneling/Proxy_Auto-Configuration_(PAC)_file#localHostOrDomainIs

If you use host or url variable should not make much of a difference though; as said url is equal to host:port
means for https:foo.bar.com:1234
host=foo.bar.com
url:1234=foo.bar.com