Skip to content

Commit

Permalink
fix: allow {accept} file selection w/o using the OS options
Browse files Browse the repository at this point in the history
  • Loading branch information
unimonkiez committed Jul 3, 2022
1 parent 86ea1df commit 8127759
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
17 changes: 12 additions & 5 deletions src/utils/index.js
Expand Up @@ -197,7 +197,7 @@ export function canUseFileSystemAccessAPI() {
*/
export function pickerOptionsFromAccept(accept) {
if (isDefined(accept)) {
return Object.entries(accept)
const acceptForPicker = Object.entries(accept)
.filter(([mimeType, ext]) => {
let ok = true;

Expand All @@ -217,11 +217,18 @@ export function pickerOptionsFromAccept(accept) {

return ok;
})
.map(([mimeType, ext]) => ({
accept: {
.reduce(
(agg, [mimeType, ext]) => ({
...agg,
[mimeType]: ext,
},
}));
}),
{}
);
return [
{
accept: acceptForPicker,
},
];
}
return accept;
}
Expand Down
4 changes: 0 additions & 4 deletions src/utils/index.spec.js
Expand Up @@ -415,10 +415,6 @@ describe("pickerOptionsFromAccept()", () => {
{
accept: {
"image/*": [".png", ".jpg"],
},
},
{
accept: {
"text/*": [".txt", ".pdf"],
},
},
Expand Down

0 comments on commit 8127759

Please sign in to comment.