一个包含所有受信任服务器的单例。任何对这些服务器的请求都会附带凭据。
Methods
向注册表中添加一个受信任的服务器。
| Name | Type | Description |
|---|---|---|
host |
string | 要添加的主机。 |
port |
number | 用于访问主机的端口。 |
Example:
// Add a trusted server
TrustedServers.add('my.server.com', 80);
清空注册表。
Example:
// Remove a trusted server
TrustedServers.clear();
测试某个服务器是否受信任。如果该服务器在 url 中包含端口,则必须使用端口添加它。
| Name | Type | Description |
|---|---|---|
url |
string | 要与受信任列表进行比对的 url。 |
Returns:
如果 url 受信任则返回 true,否则返回 false。
Example:
// Add server
TrustedServers.add('my.server.com', 81);
// Check if server is trusted
if (TrustedServers.contains('https://my.server.com:81/path/to/file.png')) {
// my.server.com:81 is trusted
}
if (TrustedServers.contains('https://my.server.com/path/to/file.png')) {
// my.server.com isn't trusted
}
从注册表中移除一个受信任的服务器。
| Name | Type | Description |
|---|---|---|
host |
string | 要移除的主机。 |
port |
number | 用于访问主机的端口。 |
Example:
// Remove a trusted server
TrustedServers.remove('my.server.com', 80);
