mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-10-22 21:25:27 +00:00
Fix RSS discovery for pages without updates (#4626)
This commit is contained in:
@@ -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"');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user