From 2f1050ec1064601d9761fd281626b34119049363 Mon Sep 17 00:00:00 2001 From: Edgar Silva Date: Wed, 16 Feb 2022 18:50:21 +0000 Subject: [PATCH] Updated gitlab integration to include port Updated integration module to allow for the use of a custom port, which is often the case in self hosted gitlab instances Removed host.includes(':') check in config.ts to allow for users to include the port in the host Changed url.hostname to url.host in core.ts to include the port in the api call (otherwise it'll result in an error when trying to import a new component) Signed-off-by: Edgar Silva --- packages/integration/src/gitlab/config.ts | 6 +----- packages/integration/src/gitlab/core.ts | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/integration/src/gitlab/config.ts b/packages/integration/src/gitlab/config.ts index f74b849c74..71b4cd868f 100644 --- a/packages/integration/src/gitlab/config.ts +++ b/packages/integration/src/gitlab/config.ts @@ -82,11 +82,7 @@ export function readGitLabIntegrationConfig( baseUrl = `https://${host}`; } - if (host.includes(':')) { - throw new Error( - `Invalid GitLab integration config, host '${host}' should just be the host name (e.g. "github.com"), not a URL`, - ); - } else if (!isValidHost(host)) { + if (!isValidHost(host)) { throw new Error( `Invalid GitLab integration config, '${host}' is not a valid host`, ); diff --git a/packages/integration/src/gitlab/core.ts b/packages/integration/src/gitlab/core.ts index c5b0713340..f7dfd26d78 100644 --- a/packages/integration/src/gitlab/core.ts +++ b/packages/integration/src/gitlab/core.ts @@ -138,7 +138,7 @@ export async function getProjectId( // Convert // to: https://gitlab.com/api/v4/projects/groupA%2Fteams%2FsubgroupA%2FteamA%2Frepo const repoIDLookup = new URL( - `${url.protocol + url.hostname}/api/v4/projects/${encodeURIComponent( + `${url.protocol + url.host}/api/v4/projects/${encodeURIComponent( repo.replace(/^\//, ''), )}`, );