ianstormtaylor/slate-plugins

slate-drop-or-paste-images: Error is thrown if file has no extension

tommoor opened this issue ยท 1 comments

Do you want to request a feature or report a bug?

Bug ๐Ÿ›

What's the current behavior?

  • Create a file with no extension
  • Drag and drop into editor
  • A JS error is thrown: Uncaught TypeError: Cannot read property 'includes' of undefined

What's the expected behavior?

  • The plugin accounts for this type of file

The problem is that ext can become undefined at

const [, ext] = type.split('/')

But that code is bad anyway, it won't handle .foo.jpg or bar.old.jpg. Better to use a regex like /([^.]+)$/.exec(name)