File tree Expand file tree Collapse file tree 1 file changed +3
-9
lines changed
packages/common/pipes/file Expand file tree Collapse file tree 1 file changed +3
-9
lines changed Original file line number Diff line number Diff line change 11import { FileValidator } from './file-validator.interface' ;
22import { FileTypeValidatorOptions , IFile } from './interfaces' ;
33
4- const importEsmPackage = async (
5- packageName : string ,
6- ) : Promise < typeof import ( 'file-type' ) > =>
7- // eslint-disable-next-line @typescript-eslint/no-implied-eval
8- new Function ( `return import('${ packageName } ')` ) ( ) . then (
9- ( loadedModule : any ) => loadedModule [ 'default' ] ?? loadedModule ,
10- ) ;
11-
124/**
135 * Defines the built-in FileTypeValidator. It validates incoming files by examining
146 * their magic numbers using the file-type package, providing more reliable file type validation
@@ -47,7 +39,9 @@ export class FileTypeValidator extends FileValidator<
4739 }
4840
4941 try {
50- const { fileTypeFromBuffer } = await importEsmPackage ( 'file-type' ) ;
42+ const { fileTypeFromBuffer } = ( await eval (
43+ 'import ("file-type")' ,
44+ ) ) as typeof import ( 'file-type' ) ;
5145
5246 const fileType = await fileTypeFromBuffer ( file . buffer ) ;
5347
You can’t perform that action at this time.
0 commit comments