Skip to content

Commit

Permalink
Merge pull request #211 from storybookjs/fix-links-regex
Browse files Browse the repository at this point in the history
Fix link regex
  • Loading branch information
cdedreuille committed Jul 18, 2024
2 parents 00c2b02 + 48dc41e commit 15bd3ad
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions apps/frontpage/components/docs/mdx/a.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function getParentPartOfPath(
return indexPagePath.length === 1
? activeVersion.id === latestVersion.id
? 'docs'
: activeVersion.inSlug ?? activeVersion.id
: (activeVersion.inSlug ?? activeVersion.id)
: indexPagePath[indexPagePath.length - 1];
}

Expand All @@ -45,13 +45,12 @@ export const A: FC<AProps> = ({
}

let href = hrefIn
?.replace(/^(?:(?!http).*)\.mdx/, '$1')
// eslint-disable-next-line prefer-named-capture-group -- TODO: Fix regex with new eslint rules
?.replace(/^((?!http).*)\.mdx/, '$1')
.replace(/\/index$/, '')
// ../../release-7-6/docs/migration-guide.mdx#major-breaking-changes -> ../../docs/7/migration-guide#major-breaking-changes
.replace(
/^(?:(?!http).*)(?:release-)(?:\d+)-\d+\/docs(?:.*)/,
'$1docs/$2$3',
);
// eslint-disable-next-line prefer-named-capture-group -- TODO: Fix regex with new eslint rules
.replace(/^((?!http).*)(?:release-)(\d+)-\d+\/docs(.*)/, '$1docs/$2$3');

if (indexPagePath && href?.startsWith('./')) {
href = href.replace(
Expand Down

0 comments on commit 15bd3ad

Please sign in to comment.