From 99e3795619dddf2c90ab416cc04bf3d5165ed8fc Mon Sep 17 00:00:00 2001 From: Berry de Vos Date: Thu, 19 Oct 2023 18:15:08 +0200 Subject: [PATCH] Something in the paragraphs from daring fireball feed broke the output, build in a tiny tiny bit more secure parsing --- src/email/Summary.tsx | 2 +- src/email/daringfireball/Summary.tsx | 2 +- src/email/parseLinks.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/email/Summary.tsx b/src/email/Summary.tsx index 9b06f97..ff82ea0 100644 --- a/src/email/Summary.tsx +++ b/src/email/Summary.tsx @@ -20,7 +20,7 @@ export default ({ content, href, paragraphStyle, blockquoteStyle }: Props) => { return ( <> - {elements[0].text} + {elements.at(0)?.text} {elements.length > 1 && ( … diff --git a/src/email/daringfireball/Summary.tsx b/src/email/daringfireball/Summary.tsx index e10aba5..ece52be 100644 --- a/src/email/daringfireball/Summary.tsx +++ b/src/email/daringfireball/Summary.tsx @@ -30,7 +30,7 @@ export default ({ content, href }: Props) => { const paragraphs = element.querySelectorAll('> p') return ( - {paragraphs[0].text ?? ''} + {paragraphs.at(0)?.text ?? ''} {blockquoteHasMore && ( diff --git a/src/email/parseLinks.ts b/src/email/parseLinks.ts index f64afeb..7b0a5fd 100644 --- a/src/email/parseLinks.ts +++ b/src/email/parseLinks.ts @@ -16,5 +16,5 @@ export const parseLinks = (links: ItemLink[]) => { return `${links[0]}` } - return hrefByRel(links, 'related') ?? hrefByRel(links, 'alternate') ?? links[0].$.href + return hrefByRel(links, 'related') ?? hrefByRel(links, 'alternate') ?? links.at(0)?.$.href }