Fix 404 when accessing rss.xml for the root page (#3896)

This commit is contained in:
Samy Pessé
2026-01-09 16:05:31 +01:00
committed by GitHub
parent 56fb754e22
commit ca682362dd
3 changed files with 18 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"gitbook": patch
---
Fix 404 when accessing rss.xml for the root page.
+5
View File
@@ -83,6 +83,11 @@ export function getPagePathFromParams(params: RouteParams) {
// If decoding the param fails, return a 404 instead of crashing
try {
const decoded = decodeURIComponent(params.pagePath);
// For the root page, we encode '/' to avoid an empty param being passed.
if (decoded === '/') {
return '';
}
return decoded;
} catch (error) {
console.error(
+8
View File
@@ -19,4 +19,12 @@ it('should not expose a RSS feed for a page without updates', async () => {
);
const response = await fetch(feedURL);
expect(response.status).toBe(404);
expect(await response.text()).toBe('No updates found in page');
});
it('should not expose a RSS feed for a page without updates (root page)', async () => {
const feedURL = getContentTestURL('https://gitbook.gitbook.io/test-gitbook-open/rss.xml');
const response = await fetch(feedURL);
expect(response.status).toBe(404);
expect(await response.text()).toBe('No updates found in page');
});