|
|
@@ -765,12 +765,23 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
resolveHrefs() {
|
|
|
this.doc.querySelectorAll("a[href], area[href], link[href]").forEach(element => {
|
|
|
const href = element.getAttribute("href").trim();
|
|
|
- if (!Util.testIgnoredPath(href) && !href.startsWith("#")) {
|
|
|
+ if (!Util.testIgnoredPath(href)) {
|
|
|
+ let resolvedURL;
|
|
|
try {
|
|
|
- element.setAttribute("href", docUtil.resolveURL(href, this.options.baseURI || this.options.url));
|
|
|
+ resolvedURL = docUtil.resolveURL(href, this.options.baseURI || this.options.url);
|
|
|
} catch (error) {
|
|
|
// ignored
|
|
|
}
|
|
|
+ if (resolvedURL) {
|
|
|
+ if (resolvedURL.startsWith(this.options.url + "#")) {
|
|
|
+ resolvedURL = resolvedURL.substring(this.options.url.length);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ element.setAttribute("href", resolvedURL);
|
|
|
+ } catch (error) {
|
|
|
+ // ignored
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
}
|