forked from mirrors/gecko-dev
		
	 9d2d9836e6
			
		
	
	
		9d2d9836e6
		
	
	
	
	
		
			
			Differential Revision: https://phabricator.services.mozilla.com/D5914 --HG-- extra : moz-landing-system : lando
		
			
				
	
	
		
			17 lines
		
	
	
	
		
			388 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			17 lines
		
	
	
	
		
			388 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| export function safeURI(url) {
 | |
|   if (!url) {
 | |
|     return "";
 | |
|   }
 | |
|   const {protocol} = new URL(url);
 | |
|   const isAllowed = [
 | |
|     "http:",
 | |
|     "https:",
 | |
|     "data:",
 | |
|     "resource:",
 | |
|     "chrome:",
 | |
|   ].includes(protocol);
 | |
|   if (!isAllowed) {
 | |
|     console.warn(`The protocol ${protocol} is not allowed for template URLs.`); // eslint-disable-line no-console
 | |
|   }
 | |
|   return isAllowed ? url : "";
 | |
| }
 |