mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-02 13:03:22 +00:00
Check for duplicate domains
This commit is contained in:
@@ -73,7 +73,23 @@ class DomainUtil {
|
||||
this.reloadDB();
|
||||
}
|
||||
|
||||
// Check if domain is already added
|
||||
duplicateDomain(domain) {
|
||||
const servers = this.getDomains();
|
||||
for (const i in servers) {
|
||||
if (servers[i].url === domain) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
checkDomain(domain) {
|
||||
if (this.duplicateDomain(domain)) {
|
||||
alert('This Server Address already exists.');
|
||||
return;
|
||||
}
|
||||
|
||||
const hasPrefix = (domain.indexOf('http') === 0);
|
||||
if (!hasPrefix) {
|
||||
domain = (domain.indexOf('localhost:') >= 0) ? `http://${domain}` : `https://${domain}`;
|
||||
|
||||
Reference in New Issue
Block a user