From 14083377d1877a6a766b0a33e3f5c5db1c984b0e Mon Sep 17 00:00:00 2001 From: Patrick Farwick <9168045+MinecraftPlaye@users.noreply.github.com> Date: Sat, 22 Jan 2022 01:00:03 +0000 Subject: [PATCH] Only use comic pages for internal calculations A comic book archive stores pages as images, but can store other information like metadata within the file, too. This change uses only the image based files as pages and ignores other files. --- src/plugins/comicsPlayer/plugin.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/comicsPlayer/plugin.js b/src/plugins/comicsPlayer/plugin.js index 3f6f844e3e..6f53d28786 100644 --- a/src/plugins/comicsPlayer/plugin.js +++ b/src/plugins/comicsPlayer/plugin.js @@ -259,7 +259,15 @@ class ArchiveSource { this.raw = await this.archive.getFilesArray(); await this.archive.extractFiles(); - const files = await this.archive.getFilesArray(); + // the comic book archive supports any kind of image format as it's just a zip archive + const supportedFormats = ['jpg', 'png', 'avif', 'gif', 'bmp', 'dib', 'tiff', 'tif']; + + let files = await this.archive.getFilesArray(); + files = files.filter((file) => { + const name = file.file.name; + const index = name.lastIndexOf('.'); + return supportedFormats.includes(name.substr(index + 1)); + }); files.sort((a, b) => { if (a.file.name < b.file.name) { return -1;