fix htmldecode: do in two passes

This commit is contained in:
Wouter Groeneveld 2021-03-13 15:25:28 +01:00
parent 8598a898f4
commit 24f6d1a8e3
3 changed files with 5 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{
"name": "jam-my-stack",
"version": "1.0.8",
"version": "1.0.9",
"repository": {
"url": "https://github.com/wgroeneveld/jam-my-stack",
"type": "git"

View File

@ -73,9 +73,10 @@ async function parseMastoFeed(options) {
// format: <thr:in-reply-to ref='https://social.linux.pizza/users/StampedingLonghorn/statuses/105821099684887793' href='https://social.linux.pizza/users/StampedingLonghorn/statuses/105821099684887793'/>
const context = item['thr:in-reply-to'] ? item['thr:in-reply-to']['@_ref'] : ""
// WHY double decode? &#34; = &amp;#34; - first decode '&', then the other char.'
return {
title: trimIfNeeded(ent.decode(item.title), titleCount, titlePrefix), // summary (cut-off) of content
content: ent.decode(item.content['#text']), // format: &lt;span class=&quot;h-card....
title: trimIfNeeded(ent.decode(ent.decode(item.title)), titleCount, titlePrefix), // summary (cut-off) of content
content: ent.decode(ent.decode(item.content['#text'])), // format: &lt;span class=&quot;h-card....
url: item.id, // format: https://chat.brainbaking.com/objects/0707fd54-185d-4ee7-9204-be370d57663c
context,
id: stripBeforeLastSlash(item.id),

View File

@ -44,7 +44,7 @@ describe("mastodon feed parser tests", () => {
const actualMd = await fsp.readFile(`${dumpdir}/2021/03/02h16m18s46.md`)
const md = frontMatterParser.parseSync(actualMd.toString())
expect(md.data.title).toBe("@StampedingLonghorn I tried to chase him away, but you know how that turned out... 😼 There&#39;s ...")
expect(md.data.title).toBe("@StampedingLonghorn I tried to chase him away, but you know how that turned out... 😼 There's ...")
})
test("parse creates separate notes in each month subdir", async () => {