@@ -4,9 +4,9 @@ import { DataMapperMetadataService } from '../../../services/datamapper-metadata
44import { DataMapperStepService } from '../../../services/datamapper-step.service' ;
55import { SchemaFileItem , SchemaFileMessage } from './AttachSchema/SchemaFileDataList' ;
66
7- const VALID_XML_EXTENSIONS = [ '.xml' , '.xsd' ] ;
8- const VALID_JSON_EXTENSIONS = [ '.json' ] ;
9- export const VALID_ALL_EXTENSIONS = [ ...VALID_XML_EXTENSIONS , ...VALID_JSON_EXTENSIONS ] ;
7+ const VALID_XML_EXTENSIONS = new Set ( [ '.xml' , '.xsd' ] ) ;
8+ const VALID_JSON_EXTENSIONS = new Set ( [ '.json' ] ) ;
9+ export const VALID_ALL_EXTENSIONS = new Set ( [ ...VALID_XML_EXTENSIONS , ...VALID_JSON_EXTENSIONS ] ) ;
1010
1111export function getFileExtension ( filePath : string ) : string {
1212 return filePath . toLowerCase ( ) . substring ( filePath . lastIndexOf ( '.' ) ) ;
@@ -17,11 +17,11 @@ export function getFileName(filePath: string): string {
1717}
1818
1919export function isXmlExtension ( ext : string ) : boolean {
20- return VALID_XML_EXTENSIONS . includes ( ext ) ;
20+ return VALID_XML_EXTENSIONS . has ( ext ) ;
2121}
2222
2323export function isJsonExtension ( ext : string ) : boolean {
24- return VALID_JSON_EXTENSIONS . includes ( ext ) ;
24+ return VALID_JSON_EXTENSIONS . has ( ext ) ;
2525}
2626
2727/** Public for tests only */
@@ -36,7 +36,7 @@ export async function validateFileExtension(ext: string, documentType: DocumentT
3636 }
3737 return undefined ;
3838 }
39- if ( ! VALID_ALL_EXTENSIONS . includes ( ext ) ) {
39+ if ( ! VALID_ALL_EXTENSIONS . has ( ext ) ) {
4040 return `Unknown file extension '${ ext } '. Either XML schema (.xsd, .xml) or JSON schema (.json) file is supported.` ;
4141 }
4242 return undefined ;
0 commit comments