From 194e53fb714498eec0254f34cfa022bfaec72fd3 Mon Sep 17 00:00:00 2001 From: saragajic11 Date: Mon, 10 Jun 2024 14:41:05 +0200 Subject: [PATCH] using URL instead of regex --- eds/components/PartnerCards.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/eds/components/PartnerCards.js b/eds/components/PartnerCards.js index 97eeea8..dda38d6 100644 --- a/eds/components/PartnerCards.js +++ b/eds/components/PartnerCards.js @@ -29,7 +29,13 @@ class NewsCard extends LitElement { console.error('URL is null or undefined'); return ''; } - return window.location.host === 'partners.adobe.com' ? url : url.replace(/^(https?:\/\/)[^\/]+/, `${window.location.protocol}//${window.location.host}`); + if(window.location.host === 'partners.adobe.com') { + return url; + } + const newUrl = new URL(url); + newUrl.protocol = window.location.protocol; + newUrl.host = window.location.host; + return newUrl; } render() {