Skip to content

Commit

Permalink
Fix #292: return direct for *.local host in PAC.
Browse files Browse the repository at this point in the history
  • Loading branch information
cyfdecyf authored and renzhn committed May 8, 2015
1 parent 8b4ca6e commit d8a4984
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pac.go
Expand Up @@ -80,6 +80,9 @@ function host2Domain(host) {
function FindProxyForURL(url, host) {
if (url.substring(0,4) == "ftp:")
return direct;
if (host.indexOf(".local", host.length - 6) !== -1) {
return direct;
}
return (directAcc[host] || directAcc[host2Domain(host)]) ? direct : httpProxy;
}
`
Expand Down
9 changes: 8 additions & 1 deletion pac.js
Expand Up @@ -68,6 +68,9 @@ function host2Domain(host) {
function FindProxyForURL(url, host) {
if (url.substring(0,4) == "ftp:")
return direct;
if (host.indexOf(".local", host.length - 6) !== -1) {
return direct;
}
return (directAcc[host] || directAcc[host2Domain(host)]) ? direct : httpProxy;
}

Expand Down Expand Up @@ -138,7 +141,11 @@ testData = [
{ host: 'foo.taobao.com', mode: httpProxy},
{ host: 'google.com', mode: httpProxy},
{ host: 'www.google.com', mode: httpProxy},
{ host: 'www.google.com.hk', mode: httpProxy}
{ host: 'www.google.com.hk', mode: httpProxy},

// host in local domain should return direct
{ host: 'test.local', mode: direct},
{ host: '.local', mode: direct},
];

for (i = 0; i < testData.length; i += 1) {
Expand Down

0 comments on commit d8a4984

Please sign in to comment.