shExpMatch()和之间有什么区别dnsDomainIs()
定义说:
// dnsDomainIs()
// Evaluates hostnames and returns true if hostnames match. Used mainly to match and exception individual host names.
// Example:
if (dnsDomainIs(host, ".google.com")) return "DIRECT";
// shExpMatch()
// Attempts to match hostname or URL to a specified shell expression and returns true if matched.
// Example:
if (shExpMatch(url, "*vpn.domain.com*") ||
shExpMatch(url, "*abcdomain.com/folder/*"))
return "DIRECT";
Run Code Online (Sandbox Code Playgroud)
如果我理解正确的话
shExpMatch() - 可以使用一些通配符
dnsDomainIs() - 可以使用确切的名称
是shExpMatch()优越的dnsDomainIs()
查看来自http://findproxyforurl.com/pac-functions/的定义,它们具有非常不同的功能。dnsDomainIs() 使用精确的域名 - 例如.google.com,而 shExpMatch() 使用类似 shell 的字符串和通配符,例如*.google.com.
它们现在看起来非常不同,但是使用 shExpMatch,您还可以匹配文件夹结构中的项目,例如example.com/sub/folder/*或http://example.com/img/*.png。
第一个只匹配主机名,没有协议、端口或子文件夹,而第二个匹配整个 URL。但是,您可能可以像 dnsDomainIs() 一样使用 shExpMatch(),但我不确定,如果您可能容易受到攻击,那么通过无意中允许像google.com.example.comfor google.com- dnsDomainIs()这样的 URL会在此处返回 false,shExpMatch() 可能会返回 true (未测试,只是预感)
| 归档时间: |
|
| 查看次数: |
17254 次 |
| 最近记录: |