Skip to content

Commit 3b0eff7

Browse files
authored
Fix getRevisionPageByPath in v2 not encoding the path correctly (#3121)
1 parent c765463 commit 3b0eff7

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

packages/gitbook-v2/src/lib/data/api.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ const getRevisionPageByPath = withCacheKey(
531531
) => {
532532
const uncached = unstable_cache(
533533
async () => getRevisionPageByPathUncached(cacheKey, input, params),
534-
[cacheKey],
534+
[cacheKey, 'v2'],
535535
{
536536
revalidate: RevalidationProfile.max,
537537
tags: [],
@@ -551,12 +551,13 @@ const getRevisionPageByPathUncached = withoutConcurrentExecution(
551551
return trace(
552552
`getRevisionPageByPath.uncached(${params.spaceId}, ${params.revisionId}, ${params.path})`,
553553
async () => {
554+
const encodedPath = encodeURIComponent(params.path);
554555
return wrapDataFetcherError(async () => {
555556
const api = apiClient(input);
556557
const res = await api.spaces.getPageInRevisionByPath(
557558
params.spaceId,
558559
params.revisionId,
559-
params.path,
560+
encodedPath,
560561
{}
561562
);
562563
return res.data;

packages/gitbook/e2e/internal.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,20 @@ const testCases: TestsCase[] = [
837837
},
838838
],
839839
},
840+
{
841+
name: 'Content Redirects',
842+
contentBaseURL: 'https://gitbook-open-e2e-sites.gitbook.io/gitbook-doc/',
843+
tests: [
844+
{
845+
name: 'Redirect to new location',
846+
url: '/content-editor/editing-content/inline/redirect-test',
847+
run: async (page) => {
848+
await expect(page.locator('h1')).toHaveText('Redirect test');
849+
},
850+
screenshot: false,
851+
},
852+
],
853+
},
840854
{
841855
name: 'Site Redirects with sections',
842856
contentBaseURL: 'https://gitbook-open-e2e-sites.gitbook.io/sections/',

0 commit comments

Comments
 (0)