mirror of
				https://github.com/crazy-max/ghaction-upx.git
				synced 2025-11-04 04:58:11 -07:00 
			
		
		
		
	
		
			
				
	
	
		
			16 lines
		
	
	
		
			387 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			16 lines
		
	
	
		
			387 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
'use strict';
 | 
						|
module.exports = (url, opts) => {
 | 
						|
	if (typeof url !== 'string') {
 | 
						|
		throw new TypeError(`Expected \`url\` to be of type \`string\`, got \`${typeof url}\``);
 | 
						|
	}
 | 
						|
 | 
						|
	url = url.trim();
 | 
						|
	opts = Object.assign({https: false}, opts);
 | 
						|
 | 
						|
	if (/^\.*\/|^(?!localhost)\w+:/.test(url)) {
 | 
						|
		return url;
 | 
						|
	}
 | 
						|
 | 
						|
	return url.replace(/^(?!(?:\w+:)?\/\/)/, opts.https ? 'https://' : 'http://');
 | 
						|
};
 |