How can I block URLs ending with ".pdf" in a PAC file? `shExpMatch()` doesn't work on iOS

258 Views Asked by At

Context

I’m deploying a Proxy Auto-Config (PAC) file through JAMF MDM using the auto global HTTP proxy. The purpose of this file is to block some traffic on the network level. We’re deploying the PAC files on iPhones.

I tried to block all URLs ending with .pdf by using shExpMatch():

shExpMatch(url, “.*pdf”)

But iOS seems to just skip that line without implementing it. Am I doing something wrong or is there an apple specific function that I should use?

Here is my full code:

function FindProxyForURL(url, host)
{
    url = url.toLowerCase();
    host = host.toLowerCase();
    if (
       url.match(".pdf")
    || shExpMatch(url, ".*pdf")
    || _dnsDomainIs(host, "api.giphy.com")
    ) {
    // deny this request
    return blackhole;

    } else {
    return normal;
    }
}

Question

  • How can I block any link ending with ".pdf" using a PAC file on IOS?
0

There are 0 best solutions below