From 0ad562c46cdbefb9d2d50402a5098b9454c7201e Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Thu, 3 Aug 2023 15:50:56 +0800 Subject: [PATCH] fix parsing rss item link error because links can be an array of string too --- packages/rss-handler/src/index.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/rss-handler/src/index.ts b/packages/rss-handler/src/index.ts index a44686dc3..f4597b98e 100644 --- a/packages/rss-handler/src/index.ts +++ b/packages/rss-handler/src/index.ts @@ -12,13 +12,8 @@ interface RssFeedRequest { lastFetchedAt: number // unix timestamp in milliseconds } -interface RssFeedItemLink { - $: { - rel?: string - href: string - type?: string - } -} +// link can be a string or an object +type RssFeedItemLink = string | { $: { rel?: string; href: string } } function isRssFeedRequest(body: any): body is RssFeedRequest { return ( @@ -134,6 +129,11 @@ const getLink = (links: RssFeedItemLink[]) => { const sortedLinks: string[] = [] links.forEach((link) => { + // if link is a string, it is the href + if (typeof link === 'string') { + return sortedLinks.push(link) + } + if (link.$.rel === 'via') { sortedLinks[0] = link.$.href }