Skip to content

Commit 7ff0a35

Browse files
authored
fix: Update example.js to address react console docs bug. (#4910)
1 parent f2131b4 commit 7ff0a35

File tree

1 file changed

+3
-2
lines changed
  • packages/documentation-framework/components/example

1 file changed

+3
-2
lines changed

packages/documentation-framework/components/example/example.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,9 @@ export const Example = ({
224224
const cleanPathname = loc.pathname.replace(/\/$/, '');
225225
const sourcePath = `/${source}`;
226226

227-
// Check if the source is already in the pathname to avoid duplication
228-
if (cleanPathname.includes(sourcePath)) {
227+
// Check if the source is already at the end of the pathname to avoid duplication
228+
// Using endsWith instead of includes to prevent false positives (e.g., /react-console matching /react)
229+
if (cleanPathname.endsWith(sourcePath)) {
229230
return `${cleanPathname}/${slugger(title)}`;
230231
} else {
231232
return `${cleanPathname}${sourcePath}/${slugger(title)}`;

0 commit comments

Comments
 (0)