From 6c83ce519cf1810d53dadef965fba9dd9ab710c2 Mon Sep 17 00:00:00 2001 From: shivam-bit Date: Fri, 4 Oct 2024 19:34:28 +0530 Subject: [PATCH] Refactor GitLab validity check to include custom domain support --- .../src/content/Dashboards/ConfigureGitlabModalBody.tsx | 3 +-- web-server/src/utils/auth.ts | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/web-server/src/content/Dashboards/ConfigureGitlabModalBody.tsx b/web-server/src/content/Dashboards/ConfigureGitlabModalBody.tsx index 2868a148..6aef9ff5 100644 --- a/web-server/src/content/Dashboards/ConfigureGitlabModalBody.tsx +++ b/web-server/src/content/Dashboards/ConfigureGitlabModalBody.tsx @@ -48,10 +48,9 @@ export const ConfigureGitlabModalBody: FC<{ const checkDomainWithRegex = (domain: string) => { const regex = - /^(https:\/\/)?[a-zA-Z0-9]+([-.][a-zA-Z0-9]+)*\.[a-zA-Z]{2,}(:[0-9]{1,5})?(\/.*)?$/; + /^(https?:\/\/)[a-zA-Z0-9]+([-.][a-zA-Z0-9]+)*\.[a-zA-Z]{2,}(:[0-9]{1,5})?(\/.*)?$/; return regex.test(domain); }; - const handleTokenChange = (e: string) => { token.set(e); showScopeError.set(''); diff --git a/web-server/src/utils/auth.ts b/web-server/src/utils/auth.ts index db3fb5d4..991e78a8 100644 --- a/web-server/src/utils/auth.ts +++ b/web-server/src/utils/auth.ts @@ -67,9 +67,7 @@ export const checkGitLabValidity = async ( accessToken: string, customDomain?: string ) => { - const baseUrl = customDomain - ? `https://${customDomain}` - : 'https://gitlab.com'; + const baseUrl = customDomain || 'https://gitlab.com'; const url = `${baseUrl}/api/v4/personal_access_tokens/self`; try { const response = await axios.get(url, {