Fix SVG detection (#4401)
* Fix SVG detection * remove unnecessary import
This commit is contained in:
		
							parent
							
								
									972fb8eb40
								
							
						
					
					
						commit
						d4ff19f013
					
				
					 3 changed files with 16 additions and 4 deletions
				
			
		
							
								
								
									
										12
									
								
								src/misc/check-svg.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/misc/check-svg.ts
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,12 @@
 | 
			
		|||
import * as fs from 'fs';
 | 
			
		||||
import * as isSvg from 'is-svg';
 | 
			
		||||
 | 
			
		||||
export default function(path: string) {
 | 
			
		||||
	try {
 | 
			
		||||
		const size = fs.statSync(path).size;
 | 
			
		||||
		if (size > 1 * 1024 * 1024) return false;
 | 
			
		||||
		return isSvg(fs.readFileSync(path));
 | 
			
		||||
	} catch {
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue