Skip to content

Commit

Permalink
fix: umlaute in RSS (#1755)
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel-rw authored Dec 29, 2023
1 parent fd3f8f3 commit b6b697c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/server/api/routers/rss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ const rssFeedResultObjectSchema = z
title: z.string(),
content: z.string(),
pubDate: z.string().optional(),
})
}),
),
}),
})
}),
);

export const rssRouter = createTRPCRouter({
Expand All @@ -52,7 +52,7 @@ export const rssRouter = createTRPCRouter({
widgetId: z.string().uuid(),
feedUrls: z.array(z.string()),
configName: z.string(),
})
}),
)
.output(z.array(rssFeedResultObjectSchema))
.query(async ({ input }) => {
Expand All @@ -75,8 +75,8 @@ export const rssRouter = createTRPCRouter({

const result = await Promise.all(
input.feedUrls.map(async (feedUrl) =>
getFeedUrl(feedUrl, rssWidget.properties.dangerousAllowSanitizedItemContent)
)
getFeedUrl(feedUrl, rssWidget.properties.dangerousAllowSanitizedItemContent),
),
);

return result;
Expand Down Expand Up @@ -106,11 +106,11 @@ const getFeedUrl = async (feedUrl: string, dangerousAllowSanitizedItemContent: b
title: item.title ? decode(item.title) : undefined,
content: processItemContent(
item['content:encoded'] ?? item.content,
dangerousAllowSanitizedItemContent
dangerousAllowSanitizedItemContent,
),
enclosure: createEnclosure(item),
link: createLink(item),
})
}),
)
.sort((a: { pubDate: number }, b: { pubDate: number }) => {
if (!a.pubDate || !b.pubDate) {
Expand Down Expand Up @@ -159,7 +159,9 @@ const processItemContent = (content: string, dangerousAllowSanitizedItemContent:
});
}

return encode(content);
return encode(content, {
level: "html5"
});
};

const createLink = (item: any) => {
Expand Down

0 comments on commit b6b697c

Please sign in to comment.