Fix for 'integration.github.apiBaseUrl' configuration not properly overriding apiBaseUrl used by techdocs.

This commit is contained in:
Erik Larsson
2020-12-22 22:50:45 +01:00
parent 4c7be88707
commit 186604d350
@@ -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 {