Fix posts with relative image/links

This commit is contained in:
Marcus Noble 2020-11-18 19:02:31 +00:00
parent f7160f7a18
commit 649595ed14

View File

@ -69,7 +69,21 @@ class FeedItem extends HTMLElement {
if (p.innerText.trim() == "") { if (p.innerText.trim() == "") {
p.remove(); p.remove();
} }
}) });
let url = new URL(item.URL);
[...this.shadowRoot.querySelectorAll('img[src^="/"]')].forEach(i => {
i.src = url.origin + i.getAttribute('src');
});
[...this.shadowRoot.querySelectorAll('a[href^="/"]')].forEach(a => {
a.href = url.origin + a.getAttribute('src');
});
[...this.shadowRoot.querySelectorAll('img:not([src^=http])')].forEach(i => {
i.src = url.origin +'/'+ i.getAttribute('src');
});
[...this.shadowRoot.querySelectorAll('a:not([href^=http])')].forEach(a => {
a.href = url.origin +'/'+ a.getAttribute('src');
});
}) })
} }