MCPcopy Create free account
hub / github.com/adobe/react-spectrum / getAnchorProps

Function getAnchorProps

packages/dev/docs/src/utils.js:71–91  ·  view source on GitHub ↗
(href)

Source from the content-addressed store, hash-verified

69}
70
71export function getAnchorProps(href) {
72 if (href.startsWith('v3:') || href.startsWith('react-aria:')) {
73 let url = new URL(href);
74 return {href: getBaseUrl(url.protocol.slice(0, -1)) + '/' + url.pathname};
75 }
76
77 if (
78 !/^http/.test(href) ||
79 /localhost|reactspectrum\.blob\.core\.windows\.net|react-spectrum\.(corp\.)?adobe\.com|^#/.test(
80 href
81 )
82 ) {
83 return {};
84 }
85
86 if (/^\//.test(href)) {
87 return {};
88 }
89
90 return {target: '_blank', rel: 'noreferrer'};
91}

Callers 5

ExampleCard.jsFile · 0.90
types.jsFile · 0.90
clsxFunction · 0.90
Layout.jsFile · 0.90
PostListing.jsFile · 0.90

Calls 2

sliceMethod · 0.80
getBaseUrlFunction · 0.70

Tested by

no test coverage detected