8 lines
		
	
	
		
			237 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			8 lines
		
	
	
		
			237 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
import _toString from 'lodash/toString';
 | 
						|
 | 
						|
export function encodeString(str: unknown) {
 | 
						|
  const tempStr = _toString(str);
 | 
						|
 | 
						|
  return encodeURIComponent(tempStr).replace(/[!'()*]/g, c => `%${c.charCodeAt(0).toString(16).toUpperCase()}`);
 | 
						|
}
 |