Skip to content

Commit 1d71d85

Browse files
authored
Don't test redirect on path that are longer than 512 (GitbookIO#2255)
1 parent 4f728c0 commit 1d71d85

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/app/(space)/fetch.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,17 @@ async function resolvePage(
114114
// If page can't be found, we try with the API, in case we have a redirect
115115
// We use the raw pathname to handle special/malformed redirects setup by users in the GitSync.
116116
// The page rendering will take care of redirecting to a normalized pathname.
117-
const resolved = await getRevisionPageByPath(
118-
contentTarget.spaceId,
119-
contentTarget.revisionId,
120-
rawPathname,
121-
);
122-
if (resolved) {
123-
return resolvePageId(pages, resolved.id);
117+
//
118+
// We don't test path that are too long as GitBook doesn't support them and will return a 404 anyway.
119+
if (rawPathname.length <= 512) {
120+
const resolved = await getRevisionPageByPath(
121+
contentTarget.spaceId,
122+
contentTarget.revisionId,
123+
rawPathname,
124+
);
125+
if (resolved) {
126+
return resolvePageId(pages, resolved.id);
127+
}
124128
}
125129

126130
return undefined;

0 commit comments

Comments
 (0)