From 1ebc780cbd62cd366ee4741c10768d5799309904 Mon Sep 17 00:00:00 2001 From: Shulammite-Aso Date: Wed, 26 Jan 2022 05:15:18 +0000 Subject: [PATCH 1/3] strip off http(s) prefix from provider hostname --- components/dashboard/src/settings/Integrations.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/components/dashboard/src/settings/Integrations.tsx b/components/dashboard/src/settings/Integrations.tsx index e68e6ec12d198f..d96cfb097bc1c5 100644 --- a/components/dashboard/src/settings/Integrations.tsx +++ b/components/dashboard/src/settings/Integrations.tsx @@ -547,8 +547,17 @@ export function GitIntegrationModal(props: ({ const updateHostValue = (host: string) => { if (mode === "new") { - setHost(host); - setRedirectURL(callbackUrl(host)); + + let verifiedHost = host; + + if (host.includes("https://")) { + verifiedHost = host.replace("https://",""); + } else if (host.includes("http://")) { + verifiedHost = host.replace("http://",""); + } + + setHost(verifiedHost); + setRedirectURL(callbackUrl(verifiedHost)); setErrorMessage(undefined); } } From 8c3feed2668a65029bc5c082400a5c615fa28b7f Mon Sep 17 00:00:00 2001 From: Shulammite-Aso Date: Wed, 2 Feb 2022 23:32:05 +0100 Subject: [PATCH 2/3] use 'startsWith' instead of 'includes' use 'startsWith' method to strip off http(s) from provider hostname --- components/dashboard/src/settings/Integrations.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/dashboard/src/settings/Integrations.tsx b/components/dashboard/src/settings/Integrations.tsx index d96cfb097bc1c5..185c92a2c1ffde 100644 --- a/components/dashboard/src/settings/Integrations.tsx +++ b/components/dashboard/src/settings/Integrations.tsx @@ -550,9 +550,9 @@ export function GitIntegrationModal(props: ({ let verifiedHost = host; - if (host.includes("https://")) { + if (host.startsWith("https://")) { verifiedHost = host.replace("https://",""); - } else if (host.includes("http://")) { + } else if (host.startsWith("http://")) { verifiedHost = host.replace("http://",""); } From ea7136472aff73123b16b92964113a9313dfa0e5 Mon Sep 17 00:00:00 2001 From: Shulammite-Aso Date: Sat, 19 Feb 2022 03:10:52 +0000 Subject: [PATCH 3/3] change hostname and remove http block --- components/dashboard/src/settings/Integrations.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/components/dashboard/src/settings/Integrations.tsx b/components/dashboard/src/settings/Integrations.tsx index 185c92a2c1ffde..54d2de18586bdd 100644 --- a/components/dashboard/src/settings/Integrations.tsx +++ b/components/dashboard/src/settings/Integrations.tsx @@ -548,16 +548,14 @@ export function GitIntegrationModal(props: ({ const updateHostValue = (host: string) => { if (mode === "new") { - let verifiedHost = host; + let newHostValue = host; if (host.startsWith("https://")) { - verifiedHost = host.replace("https://",""); - } else if (host.startsWith("http://")) { - verifiedHost = host.replace("http://",""); + newHostValue = host.replace("https://",""); } - setHost(verifiedHost); - setRedirectURL(callbackUrl(verifiedHost)); + setHost(newHostValue); + setRedirectURL(callbackUrl(newHostValue)); setErrorMessage(undefined); } }