Skip to content
Permalink
Browse files

Fix error "Failed to fetch a source document" with web publications o…

…n Microsoft Edge

The problem was: The document URLs from TOC items are obtained by `anchorElem.href` property.
This href value is absolute URL that is generated from the "href" attribute value and the base URL.
On Chrome, Safari, and Firefox, this base URL is the URL of the document containing the TOC,
and works as expected. However, on Microsoft Edge, the vivliostyle-viewer URL is used as the base URL
and the `anchorElem.href` value becomes wrong URL, and causes "Failed to fetch a source document"
error.
  • Loading branch information...
MurakamiShinyu committed Aug 11, 2019
1 parent db8e9bc commit 1ed01afc8d5e279892ded3c35b21c7822b349872
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/ts/adapt/epub.ts
@@ -297,7 +297,7 @@ export class EPUBDocStore extends Ops.OPSDocStore {
});
} else {
this.loadAsJSON(
(manifestLink as any).href || manifestLink.getAttribute("href")
Base.resolveURL(manifestLink.getAttribute("href"), url)
).then(manifestObj => {
opf.initWithWebPubManifest(manifestObj, doc).then(() => {
frame.finish(opf);
@@ -1128,7 +1128,7 @@ export class OPFDoc {
"#toc a[href]";
Array.from(doc.querySelectorAll(selector)).forEach(anchorElem => {
const hrefNoFragment = Base.stripFragment(
(anchorElem as any).href || anchorElem.getAttribute("href")
Base.resolveURL(anchorElem.getAttribute("href"), this.pubURL)
);
const path = this.getPathFromURL(hrefNoFragment);
const url = path !== null ? encodeURI(path) : hrefNoFragment;

0 comments on commit 1ed01af

Please sign in to comment.
You can’t perform that action at this time.