From 8011b168b2c29ee8f1597e84a6354521f85752aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20Bl=C3=A4ttermann?= Date: Wed, 30 Nov 2022 01:35:05 +0100 Subject: [PATCH] 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. --- website/src/components/link.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/website/src/components/link.js b/website/src/components/link.js index edc330d12..1562a82c8 100644 --- a/website/src/components/link.js +++ b/website/src/components/link.js @@ -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({ ) } - const isInternal = internalRegex.test(dest) + + const isInternal = listUrlInternal.some((urlInternal) => dest.includes(urlInternal)) const relTarget = isInternal ? {} : { rel: 'noopener nofollow noreferrer', target: '_blank' } return (