Переглянути джерело

Поправлен баг - неверно определялся тип обложки

Book Pauk 2 роки тому
батько
коміт
287edf3d12
1 змінених файлів з 4 додано та 3 видалено
  1. 4 3
      server/core/fb2/Fb2Helper.js

+ 4 - 3
server/core/fb2/Fb2Helper.js

@@ -70,9 +70,6 @@ class Fb2Helper {
         if (coverImage.count) {
             const coverAttrs = coverImage.attrs();
             const href = coverAttrs[`${parser.xlinkNS}:href`];
-            let coverType = coverAttrs['content-type'];
-            coverType = (coverType == 'image/jpg' || coverType == 'application/octet-stream' ? 'image/jpeg' : coverType);
-            coverExt = (coverType == 'image/png' ? '.png' : '.jpg');
 
             if (href) {
                 const binaryId = (href[0] == '#' ? href.substring(1) : href);
@@ -84,6 +81,10 @@ class Fb2Helper {
                         return;
 
                     if (attrs.id === binaryId) {
+                        let coverType = attrs['content-type'];
+                        coverType = (coverType == 'image/jpg' || coverType == 'application/octet-stream' ? 'image/jpeg' : coverType);
+                        coverExt = (coverType == 'image/png' ? '.png' : '.jpg');
+
                         const base64 = node.text();
                         cover = (base64 ? Buffer.from(base64, 'base64') : null);
                     }