Send referrer for internal links [ci skip]

This commit is contained in:
Ines Montani 2019-09-05 10:41:46 +02:00
parent b94c34ec8f
commit 232a029de6

View File

@ -8,6 +8,8 @@ import Icon from './icon'
import classes from '../styles/link.module.sass' import classes from '../styles/link.module.sass'
import { isString } from './util' import { isString } from './util'
const internalRegex = /(http(s?)):\/\/(prodi.gy|spacy.io|irl.spacy.io)/gi
const Whitespace = ({ children }) => ( const Whitespace = ({ children }) => (
// Ensure that links are always wrapped in spaces // Ensure that links are always wrapped in spaces
<> {children} </> <> {children} </>
@ -68,13 +70,15 @@ const Link = ({
</Wrapper> </Wrapper>
) )
} }
const isInternal = internalRegex.test(dest)
const rel = isInternal ? null : 'noopener nofollow noreferrer'
return ( return (
<Wrapper> <Wrapper>
<OutboundLink <OutboundLink
href={dest} href={dest}
className={linkClassNames} className={linkClassNames}
target="_blank" target="_blank"
rel="noopener nofollow noreferrer" rel={rel}
{...other} {...other}
> >
{content} {content}