'how to fix this pac file javascript code with regex

I have some strings.

127.0.0.1:46977/safekids/permission_denied.html  
domain1.com/denied/permission_safekid.html  
domain2.eu/pkb/1144/niche/denied/permission_safekid.html  
192.168.1.6:46977/14/asp/var/denied/permission_kid.html  

And I have a pac file.

function FindProxyForURL(url, host)  
{  
    // variable strings to return  
    var proxy_yes = "myproxy:3128";  
    var proxy_no = "DIRECT";  

    if (shExpMatch(url, "*safekid*")) { return proxy_yes; }  
    if (shExpMatch(url, "*denied*")) { return proxy_yes; }  
    if (shExpMatch(url, "*block*")) { return proxy_yes; }  
    else  
    return "DIRECT";  
}  

What I want here is to use proxy if a url contains one of the following words: safekid,denied,block

But while using pac file I am not able to enable proxy if word occurs after slashes. /

It is actually working if keyword found before slash like example given below

block.blala.com

hello.safekid.com

denied.proxy.me

But it is not working if I use

myurl.com/safekid

so if keyword occured after slashed / it won't work don't know why

I hope anyone can help with this. I guess can we use regex here?



Solution 1:[1]

Chrome remove full URL for https and just forgot to tel anyone --unsafe-pac-url works until v72 and same shit with Safari

var jpeg = new RegExp(".*?zip.*?", "i");   

if ( jpeg.test("domain/2017/02/JPEG-1.zip")  ) { /// OK
    return "PROXY 127.0.0.1:8081; PROXY 127.0.0.1:8081; DIRECT";
}

if ( jpeg.test(url)  ) { /// FAIL
    return "PROXY 127.0.0.1:8081; PROXY 127.0.0.1:8081; DIRECT";
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user956584