From 117198fbf2765dbb5eefb7133413db04d65bb0ba Mon Sep 17 00:00:00 2001 From: dylan Date: Thu, 25 Dec 2025 21:13:04 +0000 Subject: [PATCH] updated getMastodonPost to parse XML correctly and removed the atom feed function i thought mastodon served atom for some reason --- utils.js | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/utils.js b/utils.js index 03be4c2..1924a6c 100644 --- a/utils.js +++ b/utils.js @@ -49,34 +49,10 @@ export async function getRSSItemTitle(feedUrl) { return { text: cleanTitle, url: link } } -export async function getAtomFeedItem(feedUrl) { - const res = await fetch(feedUrl) - const data = await res.text() - const dom = new JSDOM(data) - - // check if it's rss (item) or atom (entry) - let element = dom.window.document.querySelector('entry') - if (!element) { - element = dom.window.document.querySelector('item') - } - - const title = element.querySelector('title').textContent - - // try to get link - atom uses href attribute, rss uses text content - const linkElement = element.querySelector('link') - const link = linkElement.getAttribute('href') || linkElement.textContent.trim() - - const cleanTitle = sanitizeHtml(title, { - allowedTags: [], - allowedAttributes: {}, - })?.trim() - return { text: cleanTitle, url: link } -} - export async function getMastodonPost(feedUrl) { const res = await fetch(feedUrl) const data = await res.text() - const dom = new JSDOM(data) + const dom = new JSDOM(data, { contentType: 'text/xml' }) // get all items from the rss feed const items = dom.window.document.querySelectorAll('item')