mirror of
https://github.com/gethomepage/homepage.git
synced 2026-09-27 06:21:18 -07:00
ignore negative maxItems
This commit is contained in:
@@ -51,7 +51,8 @@ export default async function feedProxyHandler(req, res) {
|
||||
cache.put(cacheKey, items, CACHE_MS);
|
||||
}
|
||||
|
||||
const maxItems = parseInt(widget.maxItems, 10) || 5;
|
||||
const limit = parseInt(widget.maxItems, 10);
|
||||
const maxItems = limit > 0 ? limit : 5;
|
||||
const showImages = widget.images !== false && widget.images !== "false";
|
||||
|
||||
return res.status(200).json({
|
||||
|
||||
@@ -79,6 +79,16 @@ describe("widgets/feed/proxy", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it.each([-1, 0, "abc"])("falls back to 5 items for maxItems %j", async (maxItems) => {
|
||||
getServiceWidget.mockResolvedValue({ type: "feed", url: "https://example.com/feed.xml", maxItems });
|
||||
httpProxy.mockResolvedValueOnce([200, "application/rss+xml", Buffer.from(feed)]);
|
||||
|
||||
const res = createMockRes();
|
||||
await feedProxyHandler(req, res);
|
||||
|
||||
expect(res.body.items).toHaveLength(5);
|
||||
});
|
||||
|
||||
it("respects maxItems and drops images when disabled", async () => {
|
||||
getServiceWidget.mockResolvedValue({
|
||||
type: "feed",
|
||||
|
||||
Reference in New Issue
Block a user