Преглед изворни кода

thumbnail-generator: Add webp to the list of supported types (#1961)

* Add webp to the list of supported types

* add webp to tests too
Artur Paikin пре 5 година
родитељ
комит
5cfd5495ff

+ 1 - 1
packages/@uppy/utils/src/isPreviewSupported.js

@@ -2,7 +2,7 @@ module.exports = function isPreviewSupported (fileType) {
   if (!fileType) return false
   const fileTypeSpecific = fileType.split('/')[1]
   // list of images that browsers can preview
-  if (/^(jpe?g|gif|png|svg|svg\+xml|bmp)$/.test(fileTypeSpecific)) {
+  if (/^(jpe?g|gif|png|svg|svg\+xml|bmp|webp)$/.test(fileTypeSpecific)) {
     return true
   }
   return false

+ 1 - 1
packages/@uppy/utils/src/isPreviewSupported.test.js

@@ -2,7 +2,7 @@ const isPreviewSupported = require('./isPreviewSupported')
 
 describe('isPreviewSupported', () => {
   it('should return true for any filetypes that browsers can preview', () => {
-    const supported = ['image/jpeg', 'image/gif', 'image/png', 'image/svg', 'image/svg+xml', 'image/bmp', 'image/jpg']
+    const supported = ['image/jpeg', 'image/gif', 'image/png', 'image/svg', 'image/svg+xml', 'image/bmp', 'image/jpg', 'image/webp']
     supported.forEach(ext => {
       expect(isPreviewSupported(ext)).toEqual(true)
     })