Skip to content

Commit 6a24cee

Browse files
authored
Merge pull request #458 from gustavkj/fix-ghe-compatibility
Fix ghe.com compatibility
2 parents 0842e0d + 3a76a0a commit 6a24cee

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/configuration/configuration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export function getGitHubApiUri(): string {
7676
}
7777

7878
if (base.endsWith(".ghe.com")) {
79-
return `api.${base}`;
79+
return base.replace(/^(https?):\/\//, "$1://api.");
8080
} else {
8181
return `${base}/api/v3`;
8282
}

src/git/repository.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ import {Octokit} from "@octokit/rest";
44
import {canReachGitHubAPI} from "../api/canReachGitHubAPI";
55
import {handleSamlError} from "../api/handleSamlError";
66
import {getSession} from "../auth/auth";
7-
import {getRemoteName, useEnterprise} from "../configuration/configuration";
7+
import {getGitHubApiUri, getRemoteName, useEnterprise} from "../configuration/configuration";
88
import {Protocol} from "../external/protocol";
99
import {logDebug, logError} from "../log";
1010
import {API, GitExtension, RefType, RepositoryState} from "../typings/git";
1111
import {RepositoryPermission, getRepositoryPermission} from "./repository-permissions";
12-
import {getGitHubApiUri} from "../configuration/configuration";
1312

1413
interface GitHubUrls {
1514
workspaceUri: vscode.Uri;
@@ -78,7 +77,8 @@ export async function getGitHubUrls(): Promise<GitHubUrls[] | null> {
7877
if (
7978
remote.length > 0 &&
8079
(remote[0].pushUrl?.indexOf("github.com") !== -1 ||
81-
(useEnterprise() && remote[0].pushUrl?.indexOf(new URL(getGitHubApiUri()).host) !== -1))
80+
(useEnterprise() && remote[0].pushUrl?.indexOf(new URL(getGitHubApiUri()).host) !== -1) ||
81+
remote[0].pushUrl?.indexOf(".ghe.com") !== -1)
8282
) {
8383
const url = remote[0].pushUrl;
8484

0 commit comments

Comments
 (0)