A singleton that contains all of the servers that are trusted. Credentials will be sent with
any requests to these servers.
方法
Adds a trusted server to the registry
参数名称 | 类型 | 描述信息 |
---|---|---|
host |
string | The host to be added. |
port |
number | The port used to access the host. |
使用示例:
// Add a trusted server
TrustedServers.add('my.server.com', 80);
Clears the registry
使用示例:
// Remove a trusted server
TrustedServers.clear();
Tests whether a server is trusted or not. The server must have been added with the port if it is included in the url.
参数名称 | 类型 | 描述信息 |
---|---|---|
url |
string | The url to be tested against the trusted list |
返回值:
Returns true if url is trusted, false otherwise.
使用示例:
// 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
}
Removes a trusted server from the registry
参数名称 | 类型 | 描述信息 |
---|---|---|
host |
string | The host to be removed. |
port |
number | The port used to access the host. |
使用示例:
// Remove a trusted server
TrustedServers.remove('my.server.com', 80);