updated getMastodonPost to replace URLs with link emoji

This commit is contained in:
dylan 2025-12-25 21:22:42 +00:00
parent 9f63efe950
commit 3772a254c2

View file

@ -69,11 +69,14 @@ export async function getMastodonPost(feedUrl) {
const link = item.querySelector('link')?.textContent.trim()
// use description as the text, stripping HTML
const cleanText = sanitizeHtml(description, {
let cleanText = sanitizeHtml(description, {
allowedTags: [],
allowedAttributes: {},
})?.trim()
// replace URLs with link emoji
cleanText = cleanText.replace(/https?:\/\/\S+/g, '🔗').trim()
return { text: cleanText, url: link }
}
@ -81,10 +84,12 @@ export async function getMastodonPost(feedUrl) {
const firstItem = items[0]
const description = firstItem.querySelector('description')?.textContent || ''
const link = firstItem.querySelector('link')?.textContent.trim()
const cleanText = sanitizeHtml(description, {
let cleanText = sanitizeHtml(description, {
allowedTags: [],
allowedAttributes: {},
})?.trim()
// replace URLs with link emoji
cleanText = cleanText.replace(/https?:\/\/\S+/g, '🔗').trim()
return { text: cleanText, url: link }
}