mirror of
https://github.com/explosion/spaCy.git
synced 2025-06-29 17:33:10 +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 classes from '../styles/link.module.sass'
|
||||||
import { isString, isImage } from './util'
|
import { isString, isImage } from './util'
|
||||||
|
|
||||||
const internalRegex =
|
const listUrlInternal = ['prodi.gy', 'spacy.io', 'explosion.ai']
|
||||||
/(http(s?)):\/\/(prodi.gy|spacy.io|irl.spacy.io|explosion.ai|course.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} </>
|
||||||
|
@ -71,7 +69,8 @@ export default function Link({
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const isInternal = internalRegex.test(dest)
|
|
||||||
|
const isInternal = listUrlInternal.some((urlInternal) => dest.includes(urlInternal))
|
||||||
const relTarget = isInternal ? {} : { rel: 'noopener nofollow noreferrer', target: '_blank' }
|
const relTarget = isInternal ? {} : { rel: 'noopener nofollow noreferrer', target: '_blank' }
|
||||||
return (
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user