Skip to content

Commit

Permalink
fix: make allowed extensions lower case (bleenco#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
fo authored and jkuri committed Mar 7, 2017
1 parent 42c2ead commit 4b4b4b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/directives/ng-file-drop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ export class NgFileDropDirective implements OnChanges, OnInit {
return;
}

if(this.options.allowedExtensions) {
this.options.allowedExtensions = this.options.allowedExtensions.map(ext => ext.toLowerCase());
}
this.options = new NgUploaderOptions(this.options);
this.uploader.setOptions(this.options);
}
Expand Down Expand Up @@ -107,7 +110,7 @@ export class NgFileDropDirective implements OnChanges, OnInit {
if (this.options.filterExtensions && this.options.allowedExtensions && this.files && this.files.length) {
this.files = [].filter.call(this.files, (f: File) => {
let allowedExtensions = this.options.allowedExtensions || [];
if (allowedExtensions.indexOf(f.type) !== -1) {
if (allowedExtensions.indexOf(f.type.toLowerCase()) !== -1) {
return true;
}

Expand Down
6 changes: 4 additions & 2 deletions src/directives/ng-file-select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export class NgFileSelectDirective implements OnChanges {
if (!this.options || !changes) {
return;
}

if(this.options.allowedExtensions) {
this.options.allowedExtensions = this.options.allowedExtensions.map(ext => ext.toLowerCase());
}
this.uploader.setOptions(new NgUploaderOptions(this.options));

this.uploader._emitter.subscribe((data: any) => {
Expand Down Expand Up @@ -76,7 +78,7 @@ export class NgFileSelectDirective implements OnChanges {
if (this.options.filterExtensions && this.options.allowedExtensions && this.files && this.files.length) {
this.files = [].filter.call(this.files, (f: File) => {
let allowedExtensions = this.options.allowedExtensions || [];
if (allowedExtensions.toLowerCase().indexOf(f.type.toLowerCase()) !== -1) {
if (allowedExtensions.indexOf(f.type.toLowerCase()) !== -1) {
return true;
}

Expand Down

0 comments on commit 4b4b4b5

Please sign in to comment.