mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-3283] added minimatch options into the configuration to allow cu… (#3542)
* [ADF-3283] added minimatch options into the configuration to allow customisation * [ADF-3283] added documentation
This commit is contained in:
@@ -41,7 +41,10 @@ describe('UploadService', () => {
|
||||
appConfig.config = {
|
||||
ecmHost: 'http://localhost:9876/ecm',
|
||||
files: {
|
||||
excluded: ['.DS_Store', 'desktop.ini', '.git', '*.git']
|
||||
excluded: ['.DS_Store', 'desktop.ini', '.git', '*.git', '*.SWF'],
|
||||
'match-options': {
|
||||
nocase: true
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -83,6 +86,14 @@ describe('UploadService', () => {
|
||||
expect(result[0]).toBe(file2);
|
||||
});
|
||||
|
||||
it('should match the extension in case insensitive way', () => {
|
||||
const file1 = new FileModel(new File([''], 'test.swf'));
|
||||
const file2 = new FileModel(new File([''], 'readme.md'));
|
||||
const result = service.addToQueue(file1, file2);
|
||||
expect(result.length).toBe(1);
|
||||
expect(result[0]).toBe(file2);
|
||||
});
|
||||
|
||||
it('should make XHR done request after the file is added in the queue', (done) => {
|
||||
let emitter = new EventEmitter();
|
||||
|
||||
|
@@ -38,6 +38,7 @@ export class UploadService {
|
||||
private totalAborted: number = 0;
|
||||
private totalError: number = 0;
|
||||
private excludedFileList: String[] = [];
|
||||
private matchingOptions: any = null;
|
||||
|
||||
activeTask: Promise<any> = null;
|
||||
queue: FileModel[] = [];
|
||||
@@ -56,6 +57,7 @@ export class UploadService {
|
||||
constructor(protected apiService: AlfrescoApiService,
|
||||
appConfigService: AppConfigService) {
|
||||
this.excludedFileList = <String[]> appConfigService.get('files.excluded');
|
||||
this.matchingOptions = appConfigService.get('files.match-options');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +92,7 @@ export class UploadService {
|
||||
let isAllowed = true;
|
||||
|
||||
if (this.excludedFileList) {
|
||||
isAllowed = this.excludedFileList.filter(expr => minimatch(file.name, expr)).length === 0;
|
||||
isAllowed = this.excludedFileList.filter(expr => minimatch(file.name, expr, this.matchingOptions)).length === 0;
|
||||
}
|
||||
return isAllowed;
|
||||
}
|
||||
|
Reference in New Issue
Block a user