Skip to content

Commit d29d26c

Browse files
committed
Fix links opening in new tab
1 parent a1c60b3 commit d29d26c

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

packages/dev/s2-docs/src/Link.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use client';
22

33
import {focusRing, style} from '@react-spectrum/s2/style' with {type: 'macro'};
4+
import {getBaseUrl} from './pageUtils';
45
import {LinkProps, Link as S2Link} from '@react-spectrum/s2';
56
import {Link as RACLink, LinkProps as RACLinkProps} from 'react-aria-components';
67
import React from 'react';
@@ -11,12 +12,9 @@ export function Link({href, ...props}: LinkProps) {
1112
);
1213
}
1314

15+
const baseUrl = getBaseUrl((process.env.LIBRARY as any) || 'react-aria');
1416
export function getAnchorProps(href) {
15-
if (!/^http/.test(href) || /localhost|reactspectrum\.blob\.core\.windows\.net|react-spectrum\.(corp\.)?adobe\.com|^#/.test(href)) {
16-
return {};
17-
}
18-
19-
if (/^\//.test(href)) {
17+
if (!/^http/.test(href) || href.startsWith(baseUrl)) {
2018
return {};
2119
}
2220

0 commit comments

Comments
 (0)