diff --git a/web-server/src/content/Dashboards/ConfigureGitlabModalBody.tsx b/web-server/src/content/Dashboards/ConfigureGitlabModalBody.tsx index 20cdde2b..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(''); @@ -79,7 +78,7 @@ export const ConfigureGitlabModalBody: FC<{ } depFn(isLoading.true); - await checkGitLabValidity(token.value) + await checkGitLabValidity(token.value, customDomain.value) .then(async (res) => { return res; }) diff --git a/web-server/src/utils/auth.ts b/web-server/src/utils/auth.ts index a3f97507..991e78a8 100644 --- a/web-server/src/utils/auth.ts +++ b/web-server/src/utils/auth.ts @@ -63,8 +63,12 @@ export const getMissingPATScopes = async (pat: string) => { // Gitlab functions -export const checkGitLabValidity = async (accessToken: string) => { - const url = 'https://gitlab.com/api/v4/personal_access_tokens/self'; +export const checkGitLabValidity = async ( + accessToken: string, + customDomain?: string +) => { + const baseUrl = customDomain || 'https://gitlab.com'; + const url = `${baseUrl}/api/v4/personal_access_tokens/self`; try { const response = await axios.get(url, { headers: {