From 35be7e0ba7dee98952ea5b591ead2cd5e336cc0c Mon Sep 17 00:00:00 2001 From: David Graham Date: Tue, 31 Mar 2020 11:06:21 -0600 Subject: [PATCH] Filter out null file entries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We have this entry null test elsewhere but were missing it while finding the root entries in the drop transfer. > If the item isn't a file, null is returned. —https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/webkitGetAsEntry --- .eslintrc.json | 3 +++ src/attachment.ts | 8 +++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 556dd32..09f92d7 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -4,6 +4,9 @@ "plugin:github/es6", "plugin:github/typescript" ], + "rules": { + "@typescript-eslint/no-explicit-any": "off" + }, "globals": { "FileAttachmentElement": "readable" }, diff --git a/src/attachment.ts b/src/attachment.ts index 8590266..d1aa159 100644 --- a/src/attachment.ts +++ b/src/attachment.ts @@ -136,10 +136,8 @@ async function traverse(path: string, entries: FileSystemEntry[]): Promise { const entry = item.webkitGetAsEntry && item.webkitGetAsEntry() return entry && entry.isDirectory @@ -159,6 +156,7 @@ function isDirectory(transfer: DataTransfer): boolean { } function roots(transfer: DataTransfer): FileSystemEntry[] { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - return Array.from(transfer.items).map((item: any) => item.webkitGetAsEntry()) + return Array.from(transfer.items) + .map((item: any) => item.webkitGetAsEntry()) + .filter(entry => entry != null) }