我正在为浏览器编写一个 .pac 文件。我希望浏览器检查我输入的网址是否符合规则。
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";
}
问题是我想从浏览器而不是协议和主机接收完整的 url。但是现在我只能通过测试来接收url
,https://www.login.dngdang.com/
但我输入了https://www.login.dangdang.com/xxx
。怎么了?