From ca682362dd0df3e87437a730201d808221d971c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Fri, 9 Jan 2026 16:05:31 +0100 Subject: [PATCH] Fix 404 when accessing rss.xml for the root page (#3896) --- .changeset/blue-ideas-design.md | 5 +++++ packages/gitbook/src/app/utils.ts | 5 +++++ packages/gitbook/tests/rss.test.ts | 8 ++++++++ 3 files changed, 18 insertions(+) create mode 100644 .changeset/blue-ideas-design.md diff --git a/.changeset/blue-ideas-design.md b/.changeset/blue-ideas-design.md new file mode 100644 index 000000000..c7453d0d6 --- /dev/null +++ b/.changeset/blue-ideas-design.md @@ -0,0 +1,5 @@ +--- +"gitbook": patch +--- + +Fix 404 when accessing rss.xml for the root page. diff --git a/packages/gitbook/src/app/utils.ts b/packages/gitbook/src/app/utils.ts index 1118c4fc2..ff6fd6ffc 100644 --- a/packages/gitbook/src/app/utils.ts +++ b/packages/gitbook/src/app/utils.ts @@ -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( diff --git a/packages/gitbook/tests/rss.test.ts b/packages/gitbook/tests/rss.test.ts index 580c7fd43..3b50dedc2 100644 --- a/packages/gitbook/tests/rss.test.ts +++ b/packages/gitbook/tests/rss.test.ts @@ -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'); });