Skip to content

Commit cfaf078

Browse files
authored
fix(editor): handle / paths in interceptor (#4793)
Fixes FER-7568 ## Short description of the changes made - ensure we handle `/` routes properly in interceptor ## What was the motivation & context behind this PR? - fix issue where tabs with plain `/` route were going to a not found page ## How has this PR been tested? - tested with postman
1 parent f7d9cc4 commit cfaf078

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

packages/fern-dashboard/src/components/editor/link-interceptor.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ describe("getInterceptedLink", () => {
199199

200200
const result = getInterceptedLink(event, defaultMetadata);
201201

202-
expect(result).toBe("/test-org/editor/test-docs/main/");
202+
expect(result).toBe("/test-org/editor/test-docs/main/root");
203203
});
204204

205205
it("should handle empty path", () => {

packages/fern-dashboard/src/components/editor/link-interceptor.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { ROOT_SLUG_ALIAS } from "@fern-docs/components/navigation";
2+
13
export const getInterceptedLink = (
24
event: MouseEvent,
35
metadata: {
@@ -35,6 +37,11 @@ export const getInterceptedLink = (
3537
return `/${orgName}/editor/${docsUrl}/${branch}/${cleanHref}`;
3638
}
3739

40+
// Handle root path - forward to ROOT_SLUG_ALIAS
41+
if (cleanBasePath == "" && cleanHref === "") {
42+
return `/${orgName}/editor/${docsUrl}/${branch}/${ROOT_SLUG_ALIAS}`;
43+
}
44+
3845
// Otherwise, add the base path prefix
3946
const basePathPrefix = cleanBasePath ? `${cleanBasePath}/` : "";
4047
return `/${orgName}/editor/${docsUrl}/${branch}/${basePathPrefix}${cleanHref}`;

0 commit comments

Comments
 (0)