fix(core): links with target "_blank" should no be checked by the broken link checker (#9788)

This commit is contained in:
Sébastien Lorber 2024-01-25 18:18:11 +01:00 committed by GitHub
parent cce1698c60
commit 2f2ed41829
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 37 additions and 1 deletions

View file

@ -143,8 +143,13 @@ function Link(
// It is simple local anchor link targeting current page?
const isAnchorLink = targetLink?.startsWith('#') ?? false;
// See also RR logic:
// https://github.com/remix-run/react-router/blob/v5/packages/react-router-dom/modules/Link.js#L47
const hasInternalTarget = !props.target || props.target === '_self';
// Should we use a regular <a> tag instead of React-Router Link component?
const isRegularHtmlLink = !targetLink || !isInternal || isAnchorLink;
const isRegularHtmlLink =
!targetLink || !isInternal || !hasInternalTarget || isAnchorLink;
if (!noBrokenLinkCheck && (isAnchorLink || !isRegularHtmlLink)) {
brokenLinks.collectLink(targetLink!);