From 3b0eff7f71802fcd393b84bb7daffd8831357731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Tue, 8 Apr 2025 18:29:08 +0200 Subject: [PATCH] Fix getRevisionPageByPath in v2 not encoding the path correctly (#3121) --- packages/gitbook-v2/src/lib/data/api.ts | 5 +++-- packages/gitbook/e2e/internal.spec.ts | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/gitbook-v2/src/lib/data/api.ts b/packages/gitbook-v2/src/lib/data/api.ts index e308c39bb..9fe5eefab 100644 --- a/packages/gitbook-v2/src/lib/data/api.ts +++ b/packages/gitbook-v2/src/lib/data/api.ts @@ -531,7 +531,7 @@ const getRevisionPageByPath = withCacheKey( ) => { const uncached = unstable_cache( async () => getRevisionPageByPathUncached(cacheKey, input, params), - [cacheKey], + [cacheKey, 'v2'], { revalidate: RevalidationProfile.max, tags: [], @@ -551,12 +551,13 @@ const getRevisionPageByPathUncached = withoutConcurrentExecution( return trace( `getRevisionPageByPath.uncached(${params.spaceId}, ${params.revisionId}, ${params.path})`, async () => { + const encodedPath = encodeURIComponent(params.path); return wrapDataFetcherError(async () => { const api = apiClient(input); const res = await api.spaces.getPageInRevisionByPath( params.spaceId, params.revisionId, - params.path, + encodedPath, {} ); return res.data; diff --git a/packages/gitbook/e2e/internal.spec.ts b/packages/gitbook/e2e/internal.spec.ts index 4b244a0c4..05bddb28c 100644 --- a/packages/gitbook/e2e/internal.spec.ts +++ b/packages/gitbook/e2e/internal.spec.ts @@ -837,6 +837,20 @@ const testCases: TestsCase[] = [ }, ], }, + { + name: 'Content Redirects', + contentBaseURL: 'https://gitbook-open-e2e-sites.gitbook.io/gitbook-doc/', + tests: [ + { + name: 'Redirect to new location', + url: '/content-editor/editing-content/inline/redirect-test', + run: async (page) => { + await expect(page.locator('h1')).toHaveText('Redirect test'); + }, + screenshot: false, + }, + ], + }, { name: 'Site Redirects with sections', contentBaseURL: 'https://gitbook-open-e2e-sites.gitbook.io/sections/',