mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-23 19:06:31 +00:00
Fix 404 when accessing rss.xml for the root page (#3896)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Fix 404 when accessing rss.xml for the root page.
|
||||
@@ -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(
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user