Skip to content

Commit

Permalink
fix: Error occurs by links to external site in TOC
Browse files Browse the repository at this point in the history
Fixes #657
  • Loading branch information
MurakamiShinyu committed Sep 23, 2020
1 parent 9ebca3f commit fd4af3e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/core/src/vivliostyle/epub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1159,8 +1159,13 @@ export class OPFDoc {
".toc a[href]," +
"#toc a[href]";
for (const anchorElem of doc.querySelectorAll(selector)) {
const href = anchorElem.getAttribute("href");
if (/^(https?:)?\/\//.test(href)) {
// Avoid link to external resources
continue;
}
const hrefNoFragment = Base.stripFragment(
Base.resolveURL(anchorElem.getAttribute("href"), this.pubURL),
Base.resolveURL(href, this.pubURL),
);
const path = this.getPathFromURL(hrefNoFragment);
const url = path !== null ? encodeURI(path) : hrefNoFragment;
Expand Down

0 comments on commit fd4af3e

Please sign in to comment.