From c29a07ca4024db66c67c30a09b714f440c500d61 Mon Sep 17 00:00:00 2001 From: Pavel Grinchenko <53296341+pavelgrinchenko@users.noreply.github.com> Date: Wed, 15 Apr 2020 17:30:44 +0300 Subject: [PATCH] Make redirects in the Link component only for links in the current domain (#1151) Co-authored-by: Pavel Grinchenko --- src/components/Link/index.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/Link/index.tsx b/src/components/Link/index.tsx index 68ac003db1..378ddca47a 100644 --- a/src/components/Link/index.tsx +++ b/src/components/Link/index.tsx @@ -89,12 +89,15 @@ const Link: React.FC = ({ href, ...restProps }) => { href = currentLocation.pathname + href } - // Replace link href with redirect if it exists - const [, redirectUrl] = getRedirect(location.host, location.pathname) - if (redirectUrl) { - href = isRelative(redirectUrl) - ? redirectUrl + currentLocation.search - : redirectUrl + if (location.host === currentLocation.host) { + // Replace link href with redirect if it exists + const [, redirectUrl] = getRedirect(location.host, location.pathname) + + if (redirectUrl) { + href = isRelative(redirectUrl) + ? redirectUrl + currentLocation.search + : redirectUrl + } } return