Firefox中使用pac

https://campus.barracuda.com/product/websecurityservice/article/WSS/ConfigProxyWithPACFile/

https://findproxyforurl.com/pac-functions/

 

可以参考开源项目的pac设置

https://github.com/rptec/squid-PAC

function FindProxyForURL(url, host) {
    var suffix;
    var pos = host.lastIndexOf('.');
    pos = host.lastIndexOf('.', pos - 1);
    while(1) {
        if (pos <= 0) {
            if (hasOwnProperty.call(domains, host)) {
                return proxy;
            } else {
                return direct;
            }
        }
        suffix = host.substring(pos + 1);
        if (hasOwnProperty.call(domains, suffix)) {
            return proxy;
        }
        pos = host.lastIndexOf('.', pos - 1);
    }
}

 

str.lastIndexOf(searchValue[, fromIndex])

 

The hasOwnProperty() method returns a boolean indicating whether the object has the specified property as own (not inherited) property.

obj.hasOwnProperty(prop)

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty

 

关于这个函数的使用,还有一个引申的话题

https://stackoverflow.com/questions/12017693/why-use-object-prototype-hasownproperty-callmyobj-prop-instead-of-myobj-hasow 

 

posted @ 2017-05-31 13:37  ChuckLu  阅读(1175)  评论(0编辑  收藏  举报