Merge pull request #2582 from omnivore-app/fix/rss-item-link

fix parsing rss item link error because links can be an array of string too
This commit is contained in:
Hongbo Wu 2023-08-03 16:07:34 +08:00 committed by GitHub
commit 03497da863
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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
}