Fix URLs *again*

This commit is contained in:
Half-Shot 2022-06-07 10:33:50 +01:00
parent 5c899f045d
commit f8579d35a5

View File

@ -42,11 +42,13 @@ export class GithubInstance {
} }
public static baseOctokitConfig(baseUrl: URL) { public static baseOctokitConfig(baseUrl: URL) {
// Enterprise GitHub uses a /api/v3 basepath (https://github.com/octokit/octokit.js#constructor-options)
// Cloud uses api.github.com
const url = baseUrl.hostname === GITHUB_CLOUD_URL.hostname ? baseUrl : new URL("/api/v3", baseUrl);
return { return {
userAgent: UserAgent, userAgent: UserAgent,
// Enterprise GitHub uses a /api/v3 basepath (https://github.com/octokit/octokit.js#constructor-options) // Remove trailing slash, which is always included in URL objects.
// Cloud uses api.github.com baseUrl: url.toString().substring(0,-1),
baseUrl: baseUrl.hostname === GITHUB_CLOUD_URL.hostname ? baseUrl.toString() : new URL("/api/v3", baseUrl).toString(),
} }
} }