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 1
1
import { FileValidator } from './file-validator.interface' ;
2
2
import { FileTypeValidatorOptions , IFile } from './interfaces' ;
3
3
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
-
12
4
/**
13
5
* Defines the built-in FileTypeValidator. It validates incoming files by examining
14
6
* their magic numbers using the file-type package, providing more reliable file type validation
@@ -47,7 +39,9 @@ export class FileTypeValidator extends FileValidator<
47
39
}
48
40
49
41
try {
50
- const { fileTypeFromBuffer } = await importEsmPackage ( 'file-type' ) ;
42
+ const { fileTypeFromBuffer } = ( await eval (
43
+ 'import ("file-type")' ,
44
+ ) ) as typeof import ( 'file-type' ) ;
51
45
52
46
const fileType = await fileTypeFromBuffer ( file . buffer ) ;
53
47
You can’t perform that action at this time.
0 commit comments