From 8a5c0b65e71efc9dc863af6953c33e8056401870 Mon Sep 17 00:00:00 2001 From: AHReccese Date: Sun, 3 May 2026 19:00:26 -0400 Subject: [PATCH] Refactor urlValidation function in ShareModal and GetButton components to simplify URL handling by removing unnecessary protocol assignment and ensuring consistent encoding. --- src/Views/Layout/ShareModal/index.tsx | 6 ++---- src/Views/Pages/GetButton/index.tsx | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Views/Layout/ShareModal/index.tsx b/src/Views/Layout/ShareModal/index.tsx index 9ad82d9..576090b 100644 --- a/src/Views/Layout/ShareModal/index.tsx +++ b/src/Views/Layout/ShareModal/index.tsx @@ -30,13 +30,11 @@ const ShareModal = () => { // ? ------------------------- Functions ----------------------- const urlValidation = (url: string) => { - let validated = url; const decoded_url = decodeURIComponent(url); if (!url.includes('://')) { - if (decoded_url.includes('://')) return validated; - validated = `http://${url}`; + if (decoded_url.includes('://')) return url; } - return encodeURIComponent(validated); + return encodeURIComponent(url); }; const getShareLink = (service_title: string, url: string) => { diff --git a/src/Views/Pages/GetButton/index.tsx b/src/Views/Pages/GetButton/index.tsx index 4ade9d9..a955074 100644 --- a/src/Views/Pages/GetButton/index.tsx +++ b/src/Views/Pages/GetButton/index.tsx @@ -134,13 +134,11 @@ const GetButton = () => { }; const urlValidation = (url: string) => { - let validated = url; const decoded_url = decodeURIComponent(url); if (!url.includes('://')) { - if (decoded_url.includes('://')) return validated; - validated = `http://${url}`; + if (decoded_url.includes('://')) return url; } - return encodeURIComponent(validated); + return encodeURIComponent(url); }; const onCheckboxChanged = (val: ValueType | undefined, checked: boolean) => {