mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-26 01:04:34 +03:00
Fix internal link recognition
There is a problem with regex between Node and browser, and since Next runs the component on both, this create an error. `Prop `rel` did not match. Server: "null" Client: "noopener nofollow noreferrer"` This simplifies the implementation and fixes the above error.
This commit is contained in:
parent
c0fa92190c
commit
de902ca878
|
@ -7,9 +7,7 @@ import Icon from './icon'
|
|||
import classes from '../styles/link.module.sass'
|
||||
import { isString, isImage } from './util'
|
||||
|
||||
const internalRegex =
|
||||
/(http(s?)):\/\/(prodi.gy|spacy.io|irl.spacy.io|explosion.ai|course.spacy.io)/gi
|
||||
|
||||
const listUrlInternal = ['prodi.gy', 'spacy.io', 'explosion.ai']
|
||||
const Whitespace = ({ children }) => (
|
||||
// Ensure that links are always wrapped in spaces
|
||||
<> {children} </>
|
||||
|
@ -71,7 +69,8 @@ export default function Link({
|
|||
</Wrapper>
|
||||
)
|
||||
}
|
||||
const isInternal = internalRegex.test(dest)
|
||||
|
||||
const isInternal = listUrlInternal.some((urlInternal) => dest.includes(urlInternal))
|
||||
const relTarget = isInternal ? {} : { rel: 'noopener nofollow noreferrer', target: '_blank' }
|
||||
return (
|
||||
<Wrapper>
|
||||
|
|
Loading…
Reference in New Issue
Block a user