mirror of
				https://github.com/therootcompany/greenlock.js.git
				synced 2024-11-16 17:29:00 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			21 lines
		
	
	
		
			306 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			306 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| 'use strict';
 | |
| 
 | |
| var re = /^[a-zA-Z0-9\.\-]+$/;
 | |
| var punycode = require('punycode');
 | |
| 
 | |
| var utils = module.exports;
 | |
| 
 | |
| utils.isValidDomain = function (domain) {
 | |
|   if (re.test(domain)) {
 | |
|     return domain;
 | |
|   }
 | |
| 
 | |
|   domain = punycode.toASCII(domain);
 | |
| 
 | |
|   if (re.test(domain)) {
 | |
|     return domain;
 | |
|   }
 | |
| 
 | |
|   return '';
 | |
| };
 |