I'm writing a .pac file for browser. I want browser to check url that i enter matches the rules.
function FindProxyForURL(url, host) {
url=url.toLowerCase();
host=host.toLowerCase();
debugPAC ="PAC Debug Information\n";
debugPAC +="-----------------------------------\n";
debugPAC +="Machine IP: " + myIpAddress() + "\n";
debugPAC +="Hostname: " + host + "\n";
if (isResolvable(host)) {resolvableHost = "True"} else {resolvableHost = "False"};
debugPAC +="Host Resolvable: " + resolvableHost + "\n";
debugPAC +="Hostname IP: " + dnsResolve(host) + "\n";
if (isPlainHostName(host)) {plainHost = "True"} else {plainHost = "False"};
debugPAC +="Plain Hostname: " + plainHost + "\n";
debugPAC +="Domain Levels: " + dnsDomainLevels(host) + "\n";
debugPAC +="URL: " + url + "\n";
if (url.substring(0,5)=="http:") {protocol="HTTP";}
else if (url.substring(0,6)=="https:") {protocol="HTTPS";}
else if (url.substring(0,4)=="ftp:") {protocol="FTP";}
else {protocol="Unknown";}
debugPAC +="Protocol: " + protocol + "\n";
if (!shExpMatch(url,"*.(js|xml|ico|gif|png|jpg|jpeg|css|swf)*")) {alert(debugPAC);}
if(shExpMatch(url,"*://login.dangdang.com/images/bg/dataimg/dly_0807_01*"))
{
var noproxy=url;
alert("noproxy4simplejpg"+noproxy);
return "PROXY 192.168.0.101:808";
}
if(shExpMatch(url,"*://login.dangdang.com/script/sign_in2011.js"))
{
var noproxy=url;
alert("noproxy4js"+noproxy);
return "DIRECT";
}
if(shExpMatch(url,"*login.dangdang.com/*.gif*"))
{
var noproxy=url;
alert("noproxy4gif"+noproxy);
return "DIRECT";
}
if(shExpMatch(url,"*login.dangdang.com/*"))
{
var proxy=url;
alert("proxy4login"+proxy);
return "PROXY 192.168.0.101:808";
}
else
return "DIRECT";
}
The question is that i want to receive the complete url from browser rather than protocol and host . But now i can only receive url
such as https://www.login.dngdang.com/
by testing, but i entered https://www.login.dangdang.com/xxx
. what's wrong?
I see your URL uses HTTPS - https://www.login.dangdang.com/xxx
The path and query components of https:// URLs are stripped for security reasons by browsers by default.
In Chrome, you can disable this by setting PacHttpsUrlStrippingEnabled to false
In Firefox the preference is network.proxy.autoconfig_url.include_path.
It is recommended that this be set to True. The only reason to set it to False is if it causes a compatibility problem with existing PAC scripts.