Skip to content

Commit 35be7e0

Browse files
committed
Filter out null file entries
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
1 parent a62bce8 commit 35be7e0

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

.eslintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"plugin:github/es6",
55
"plugin:github/typescript"
66
],
7+
"rules": {
8+
"@typescript-eslint/no-explicit-any": "off"
9+
},
710
"globals": {
811
"FileAttachmentElement": "readable"
912
},

src/attachment.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,8 @@ async function traverse(path: string, entries: FileSystemEntry[]): Promise<Attac
136136
const results = []
137137
for (const entry of visible(entries)) {
138138
if (entry.isDirectory) {
139-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
140139
results.push(...(await traverse(entry.fullPath, await getEntries(entry as any))))
141140
} else {
142-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
143141
const file = await getFile(entry as any)
144142
results.push(new Attachment(file, path))
145143
}
@@ -150,7 +148,6 @@ async function traverse(path: string, entries: FileSystemEntry[]): Promise<Attac
150148
function isDirectory(transfer: DataTransfer): boolean {
151149
return (
152150
transfer.items &&
153-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
154151
Array.from(transfer.items).some((item: any) => {
155152
const entry = item.webkitGetAsEntry && item.webkitGetAsEntry()
156153
return entry && entry.isDirectory
@@ -159,6 +156,7 @@ function isDirectory(transfer: DataTransfer): boolean {
159156
}
160157

161158
function roots(transfer: DataTransfer): FileSystemEntry[] {
162-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
163-
return Array.from(transfer.items).map((item: any) => item.webkitGetAsEntry())
159+
return Array.from(transfer.items)
160+
.map((item: any) => item.webkitGetAsEntry())
161+
.filter(entry => entry != null)
164162
}

0 commit comments

Comments
 (0)