From dcf108e144ca5a8d33f419dbe2c62f414c35cb11 Mon Sep 17 00:00:00 2001 From: anees Date: Thu, 16 Sep 2021 06:34:02 +0500 Subject: [PATCH] pass base64 flag in coverUrl --- src/book.js | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/book.js b/src/book.js index 4243bd188..dc15b950e 100644 --- a/src/book.js +++ b/src/book.js @@ -1,5 +1,5 @@ import EventEmitter from "event-emitter"; -import {extend, defer} from "./utils/core"; +import { extend, defer } from "./utils/core"; import Url from "./utils/url"; import Path from "./utils/path"; import Spine from "./spine"; @@ -50,10 +50,10 @@ const INPUT_TYPE = { class Book { constructor(url, options) { // Allow passing just options to the Book - if (typeof(options) === "undefined" && - typeof(url) !== "string" && - url instanceof Blob === false && - url instanceof ArrayBuffer === false) { + if (typeof (options) === "undefined" && + typeof (url) !== "string" && + url instanceof Blob === false && + url instanceof ArrayBuffer === false) { options = url; url = undefined; } @@ -229,9 +229,9 @@ class Book { this.store(this.settings.store); } - if(url) { + if (url) { this.open(url, this.settings.openAs).catch((error) => { - var err = new Error("Cannot load book at "+ url ); + var err = new Error("Cannot load book at " + url); this.emit(EVENTS.BOOK.OPEN_FAILED, err); }); } @@ -261,10 +261,10 @@ class Book { this.url = new Url("/", ""); opening = this.request(input, "binary", this.settings.requestCredentials, this.settings.requestHeaders) .then(this.openEpub.bind(this)); - } else if(type == INPUT_TYPE.OPF) { + } else if (type == INPUT_TYPE.OPF) { this.url = new Url(input); opening = this.openPackaging(this.url.Path.toString()); - } else if(type == INPUT_TYPE.MANIFEST) { + } else if (type == INPUT_TYPE.MANIFEST) { this.url = new Url(input); opening = this.openManifest(this.url.Path.toString()); } else { @@ -345,7 +345,7 @@ class Book { */ load(path) { var resolved = this.resolve(path); - if(this.archived) { + if (this.archived) { return this.archive.request(resolved); } else { return this.request(resolved, null, this.settings.requestCredentials, this.settings.requestHeaders); @@ -373,7 +373,7 @@ class Book { resolved = this.path.resolve(path); } - if(absolute != false && this.url) { + if (absolute != false && this.url) { resolved = this.url.resolve(resolved); } @@ -416,7 +416,7 @@ class Book { return INPUT_TYPE.BASE64; } - if(typeof(input) != "string") { + if (typeof (input) != "string") { return INPUT_TYPE.BINARY; } @@ -433,15 +433,15 @@ class Book { return INPUT_TYPE.DIRECTORY; } - if(extension === "epub"){ + if (extension === "epub") { return INPUT_TYPE.EPUB; } - if(extension === "opf"){ + if (extension === "opf") { return INPUT_TYPE.OPF; } - if(extension === "json"){ + if (extension === "json") { return INPUT_TYPE.MANIFEST; } } @@ -496,15 +496,15 @@ class Book { this.isOpen = true; - if(this.archived || this.settings.replacements && this.settings.replacements != "none") { + if (this.archived || this.settings.replacements && this.settings.replacements != "none") { this.replacements().then(() => { this.loaded.displayOptions.then(() => { this.opening.resolve(this); }); }) - .catch((err) => { - console.error(err); - }); + .catch((err) => { + console.error(err); + }); } else { // Resolve book opened promise this.loaded.displayOptions.then(() => { @@ -670,7 +670,7 @@ class Book { } if (this.archived) { - return this.archive.createUrl(this.cover); + return this.archive.createUrl(this.cover, { "base64": (this.settings.replacements === "base64") }); } else { return this.cover; }