updated getMastodonPost to replace URLs with link emoji
This commit is contained in:
parent
9f63efe950
commit
3772a254c2
1 changed files with 7 additions and 2 deletions
9
utils.js
9
utils.js
|
|
@ -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 }
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue