GoogleChromeLabs / browser-fs-access

File System Access API with legacy fallback in the browser
https://googlechromelabs.github.io/browser-fs-access/demo/
Apache License 2.0
1.38k stars 84 forks source link

fix accept string when using mimeTypes #92

Closed skratchdot closed 2 years ago

skratchdot commented 2 years ago

I am trying to start using this library in one of my projects.

When I converted my existing app (which was using an <input type="file" />) to using the following code:

fileOpen({ mimeTypes: ['audio/*'] })

I noticed that my audio/* filter was no longer being applied.

I added some debugging code to dump the <input type="file" /> that is being generated by this library, and I noticed <input accept="a,u,d,i,o,/,*," /> is being generated:

image

To understand the effect of this code change, please see the following 2 examples:

case 1 (both mimeTypes and extensions):

before pr:

console.log(
  [
    ...['one','two'].join(),
    ['three','four'].join()
  ].join()
);
// o,n,e,,,t,w,o,three,four

after pr:

console.log(
  [
    ...['one','two'],
    ...['three','four']
  ].join()
);
// one,two,three,four

case 2 (only extensions):

before pr:

console.log(
  [
    ...[].join(),
    ['one','two'].join()
  ].join()
);
// one,two

after pr:

console.log(
  [
    ...[],
    ...['one','two']
  ].join()
);
// one,two
skratchdot commented 2 years ago

LGTM

Thank you, great catch!

Thanks for merging and releasing a new version so quickly!