Fix RSS discovery for pages without updates (#4626)

This commit is contained in:
Peter White
2026-09-21 11:45:24 +02:00
committed by GitHub
parent b95add7b27
commit 357af3f6d2
4 changed files with 33 additions and 4 deletions
+19
View File
@@ -29,3 +29,22 @@ it('should not expose a RSS feed for a page without updates (root page)', async
expect(response.status).toBe(404);
expect(await response.text()).toBe('No updates found in page');
});
for (const path of ['', '/text-page', '/blocks/updates']) {
it(`only advertises an RSS feed when the page has updates (${path || '/'})`, async () => {
const response = await fetch(
getContentTestURL(`https://gitbook.gitbook.io/test-gitbook-open${path}`),
{ headers: { 'User-Agent': 'Googlebot' } }
);
expect(response.status).toBe(200);
const html = await response.text();
const links = Array.from(html.matchAll(/<link\b[^>]*>/g), ([link]) => link).filter((link) =>
link.includes('type="application/rss+xml"')
);
expect(links).toHaveLength(path === '/blocks/updates' ? 1 : 0);
if (path === '/blocks/updates') {
expect(links[0]).toContain('/blocks/updates/rss.xml');
expect(html.slice(0, html.indexOf('</head>'))).toContain('type="application/rss+xml"');
}
});
}