From 186604d350ff796868ea09ebf3686fd656d52804 Mon Sep 17 00:00:00 2001 From: Erik Larsson Date: Tue, 22 Dec 2020 22:50:45 +0100 Subject: [PATCH] Fix for 'integration.github.apiBaseUrl' configuration not properly overriding apiBaseUrl used by techdocs. --- packages/techdocs-common/src/default-branch.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/techdocs-common/src/default-branch.ts b/packages/techdocs-common/src/default-branch.ts index 1090fcb3d3..4b44010f0c 100644 --- a/packages/techdocs-common/src/default-branch.ts +++ b/packages/techdocs-common/src/default-branch.ts @@ -50,19 +50,19 @@ interface IGitlabBranch { } function getGithubApiUrl(config: Config, url: string): URL { - const { protocol, owner, name } = parseGitUrl(url); + const { resource, owner, name } = parseGitUrl(url); const providerConfigs = config.getOptionalConfigArray('integrations.github') ?? []; - // TODO: Maybe we need to filter by host in the array, not sure about GHE - const targetProviderConfig = providerConfigs[0]; + const hostConfig = providerConfigs.filter( + providerConfig => providerConfig.getOptionalString('host') === resource, + ); const apiBaseUrl = - targetProviderConfig?.getOptionalString('integrations.github.apiBaseUrl') ?? - 'api.github.com'; + hostConfig[0]?.getOptionalString('apiBaseUrl') ?? 'https://api.github.com'; const apiRepos = 'repos'; - return new URL(`${protocol}://${apiBaseUrl}/${apiRepos}/${owner}/${name}`); + return new URL(`${apiBaseUrl}/${apiRepos}/${owner}/${name}`); } function getGitlabApiUrl(url: string): URL {