Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass base64 flag in coverUrl | Book.coverUrl() hardcoded with blob ? No Base 64 #1219

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 20 additions & 20 deletions 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";
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
});
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -416,7 +416,7 @@ class Book {
return INPUT_TYPE.BASE64;
}

if(typeof(input) != "string") {
if (typeof (input) != "string") {
return INPUT_TYPE.BINARY;
}

Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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(() => {
Expand Down Expand Up @@ -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;
}
Expand Down