diff --git a/fb2.js b/fb2.js index ce9bdc0..74784ad 100644 --- a/fb2.js +++ b/fb2.js @@ -351,6 +351,7 @@ export const makeFB2 = async blob => { } book.splitTOCHref = href => href?.split('#')?.map(x => Number(x)) ?? [] book.getTOCFragment = (doc, id) => doc.querySelector(`[${dataID}="${id}"]`) + book.isExternal = uri => /^\w+:/i.test(uri) book.destroy = () => { for (const url of urls) URL.revokeObjectURL(url) diff --git a/view.js b/view.js index d37f791..5679b93 100644 --- a/view.js +++ b/view.js @@ -357,8 +357,8 @@ export class View extends HTMLElement { const href_ = a.getAttribute('href') const href = section?.resolveHref?.(href_) ?? href_ if (book?.isExternal?.(href)) - Promise.resolve(this.#emit('external-link', { a, href }, true)) - .then(x => x ? globalThis.open(href, '_blank') : null) + Promise.resolve(this.#emit('external-link', { a, href_ }, true)) + .then(x => x ? globalThis.open(href_, '_blank') : null) .catch(e => console.error(e)) else Promise.resolve(this.#emit('link', { a, href }, true)) .then(x => x ? this.goTo(href) : null)