1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-05 15:32:55 +02:00

Resource loading fixes

This commit is contained in:
Fred Chasen 2022-12-05 12:00:30 -08:00
parent 4458c7d584
commit 7cf8dc151b
7 changed files with 3288 additions and 4971 deletions

8213
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -19,7 +19,9 @@
"author": "fchasen@gmail.com",
"license": "BSD-2-Clause",
"devDependencies": {
"@babel/core": "^7.17.9",
"@babel/cli": "^7.19.3",
"@babel/core": "^7.20.5",
"@babel/preset-env": "^7.20.2",
"@rollup/plugin-babel": "^5.3.1",
"@rollup/plugin-commonjs": "^21.0.3",
"@rollup/plugin-node-resolve": "^13.1.3",

View file

@ -5,7 +5,9 @@ import Contents from "./rendition/contents.js";
import Layout from "./rendition/layout.js";
import Epub from "./epub/epub.js";
import Manifest from "./manifest/manifest.js";
import { generateLocations } from "./utils/locations.js"
import { generateLocations } from "./utils/locations.js";
import * as core from "./utils/core.js";
import * as url from "./utils/url.js";
// import ePub from "./epub.js";
export {
Publication,
@ -15,5 +17,7 @@ export {
Rendition,
Contents,
Layout,
generateLocations
generateLocations,
core,
url
};

View file

@ -10,8 +10,8 @@ import { createUrl, resolve } from "../utils/url.js";
* @example new Manifest(manifest)
*/
class Manifest extends Publication {
constructor(url, options) {
super();
constructor(url, requestMethod, requestOptions) {
super(null, requestMethod, requestOptions);
if (url) {
this.opened = this.open(url);

View file

@ -153,7 +153,12 @@ class Publication {
return;
}
let index = 1;
for (const item of items) {
for (let item of items) {
if (typeof item === "string") {
item = {
url: item
};
}
item.url = resolve(this.url, item.url || item.href);
// TEMP hack for handling EpubCFI
const id = encodeURIComponent(filename(item.url).split(".")[0]);
@ -206,7 +211,12 @@ class Publication {
return;
}
let index = 1;
for (const item of items) {
for (let item of items) {
if (typeof item === "string") {
item = {
url: item
};
}
item.url = this.resolve(item.url || item.href);
// TEMP hack for handling EpubCFI
const id = encodeURIComponent(filename(item.url).split(".")[0]);

View file

@ -19,7 +19,7 @@ class Resource {
canonical: item.canonical,
type: item.type,
encoding: item.encoding || lookup(item.url),
properites: item.properites,
properites: item.properites || [],
rel: item.rel || [],
name: item.name,
cfiPos: item.cfiPos,
@ -80,7 +80,7 @@ class Resource {
}
set properites(properites) {
this.data.id = properites;
this.data.properites = properites;
}
get rel() {

View file

@ -43,7 +43,11 @@ export function extension(inputUrl) {
export function resolve(inputUrl, path) {
const url = createUrl(inputUrl);
return new URL(path, url).href;
if (url.origin === "http://example.com") {
return new URL(path, url).href.replace("http://example.com/", "");
} else {
return new URL(path, url).href
}
}
export function relative(inputUrl, path) {