From 5baef89e83dd4a502bfce1d014b5e15640311e14 Mon Sep 17 00:00:00 2001 From: veera Date: Sun, 15 Apr 2018 15:35:00 -0700 Subject: [PATCH] check if file has name, required for react-dropzone pull-request #594 --- src/Html5FileSelector.js | 3 +-- test/Html5FileSelctorSpec.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Html5FileSelector.js b/src/Html5FileSelector.js index 4a9c6cc..4fb0b46 100644 --- a/src/Html5FileSelector.js +++ b/src/Html5FileSelector.js @@ -46,7 +46,7 @@ function traverseDirectory(entry) { function packageFile(file, entry) { let fileTypeOverride = ''; // handle some browsers sometimes missing mime types for dropped files - const hasExtension = file.name.lastIndexOf('.') !== -1; + const hasExtension = file.name && file.name.lastIndexOf('.') !== -1; if (hasExtension && !file.type) { fileTypeOverride = mimeTypes.lookup(file.name); } @@ -122,7 +122,6 @@ export function getDataTransferFiles(dataTransfer) { * and subfolders of the dropped/selected items. */ export function getDroppedOrSelectedFiles(event) { - const dataTransfer = event.dataTransfer; if (dataTransfer && dataTransfer.items) { return getDataTransferFiles(dataTransfer).then((fileList) => { diff --git a/test/Html5FileSelctorSpec.js b/test/Html5FileSelctorSpec.js index f76ee28..7b2c0a1 100644 --- a/test/Html5FileSelctorSpec.js +++ b/test/Html5FileSelctorSpec.js @@ -6,7 +6,7 @@ */ import { expect } from 'chai'; -import Html5FileSelector from '../src/Html5FileSelector'; +import * as Html5FileSelector from '../src/Html5FileSelector'; require('babel-polyfill'); const MOCK_MEDIA_FILES = [