mirror of
				https://github.com/zulip/zulip-desktop.git
				synced 2025-10-31 20:13:43 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			30 lines
		
	
	
		
			559 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			559 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| 'use strict';
 | |
| 
 | |
| const wurl = require('wurl');
 | |
| 
 | |
| let instance = null;
 | |
| 
 | |
| class LinkUtil {
 | |
| 	constructor() {
 | |
| 		if (instance) {
 | |
| 			return instance;
 | |
| 		} else {
 | |
| 			instance = this;
 | |
| 		}
 | |
| 
 | |
| 		return instance;
 | |
| 	}
 | |
| 
 | |
| 	isInternal(currentUrl, newUrl) {
 | |
| 		const currentDomain = wurl('hostname', currentUrl);
 | |
| 		const newDomain = wurl('hostname', newUrl);
 | |
| 
 | |
| 		const skipImages = '.jpg|.gif|.png|.jpeg|.JPG|.PNG';
 | |
| 
 | |
| 		// We'll be needing this to open images in default browser
 | |
| 		return (currentDomain === newDomain) && !newUrl.match(skipImages);
 | |
| 	}
 | |
| }
 | |
| 
 | |
| module.exports = new LinkUtil();
 |