From 69c9d96f3a4d25d691b702007f95261d7598a89e Mon Sep 17 00:00:00 2001 From: Priyankar Pal <88102392+priyankarpal@users.noreply.github.com> Date: Thu, 10 Oct 2024 20:01:03 +0530 Subject: [PATCH] Client-side URL redirect Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Priyankar Pal <88102392+priyankarpal@users.noreply.github.com> --- src/common/Testimonial/TestimonialCard.jsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/common/Testimonial/TestimonialCard.jsx b/src/common/Testimonial/TestimonialCard.jsx index 099961a016..0d32173c33 100644 --- a/src/common/Testimonial/TestimonialCard.jsx +++ b/src/common/Testimonial/TestimonialCard.jsx @@ -14,11 +14,14 @@ const TestimonialCard = ({ home, quote, name, avatarUrl, category, created_at, e }); const getHostName = () => { - var url = window.location.href; - var arr = url.split('/'); - var result = arr[0] + '//' + arr[2]; - - return result; + const allowedHostnames = ['example.com', 'another-example.com']; + const url = new URL(window.location.href); + if (allowedHostnames.includes(url.hostname)) { + return `${url.protocol}//${url.hostname}`; + } else { + console.error('Hostname not allowed:', url.hostname); + return 'https://example.com'; // Safe default value + } }; function replaceWithBr() {