Skip to content

Commit

Permalink
Refactor GitLab validity check to include custom domain support
Browse files Browse the repository at this point in the history
  • Loading branch information
shivam-bit committed Oct 4, 2024
1 parent 4cf4a3b commit 6c83ce5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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('');
Expand Down
4 changes: 1 addition & 3 deletions web-server/src/utils/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down

0 comments on commit 6c83ce5

Please sign in to comment.