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 

 

相关文章:

  • 2021-12-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
  • 2021-12-02
  • 2021-07-22
  • 2021-09-11
猜你喜欢
  • 2021-11-13
  • 2021-10-17
  • 2022-01-03
  • 2022-01-06
  • 2022-12-23
  • 2022-12-23
  • 2021-04-13
相关资源
相似解决方案