1

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?

Community
  • 1
  • 1
  • According to (http://docs.oracle.com/cd/E19438-01/820-5723/adyse/), a shell expression is required. That is not the same as a regular expression. – Yunnosch Mar 31 '17 at 12:27
  • hello so any other way to achieve this ? – user3790363 Mar 31 '17 at 17:21
  • As far as I understand, you want to return one of two values, depending on whether a regex matches a string or not. Javascript is not my area. But if you find suitable javascript code around the regex, then I will help to get the regex right. – Yunnosch Mar 31 '17 at 17:26

1 Answers1

0

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";
}
user956584
  • 5,316
  • 3
  • 40
  • 50