mirror of
				https://github.com/zulip/zulip-desktop.git
				synced 2025-11-04 05:53:21 +00:00 
			
		
		
		
	Fix duplicate checking.
This commit is contained in:
		@@ -80,6 +80,7 @@ class DomainUtil {
 | 
			
		||||
 | 
			
		||||
	// Check if domain is already added
 | 
			
		||||
	duplicateDomain(domain) {
 | 
			
		||||
		domain = this.formatUrl(domain);
 | 
			
		||||
		const servers = this.getDomains();
 | 
			
		||||
		for (const i in servers) {
 | 
			
		||||
			if (servers[i].url === domain) {
 | 
			
		||||
@@ -96,10 +97,7 @@ class DomainUtil {
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		const hasPrefix = (domain.indexOf('http') === 0);
 | 
			
		||||
		if (!hasPrefix) {
 | 
			
		||||
			domain = (domain.indexOf('localhost:') >= 0) ? `http://${domain}` : `https://${domain}`;
 | 
			
		||||
		}
 | 
			
		||||
		domain = this.formatUrl(domain);
 | 
			
		||||
 | 
			
		||||
		const checkDomain = domain + '/static/audio/zulip.ogg';
 | 
			
		||||
 | 
			
		||||
@@ -232,6 +230,15 @@ class DomainUtil {
 | 
			
		||||
 | 
			
		||||
		return `${dir}/${hash >>> 0}${extension}`;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	formatUrl(domain) {
 | 
			
		||||
		const hasPrefix = (domain.indexOf('http') === 0);
 | 
			
		||||
		if (hasPrefix) {
 | 
			
		||||
			return domain;
 | 
			
		||||
		} else {
 | 
			
		||||
			return (domain.indexOf('localhost:') >= 0) ? `http://${domain}` : `https://${domain}`;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports = new DomainUtil();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user