Skip to content

Commit d6bc6ff

Browse files
authored
Merge pull request #366 from github/thyeggman/sanitize-input-url
Sanitize input URL
2 parents 2c83897 + ffeff10 commit d6bc6ff

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/git/repository.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,18 @@ export async function getGitHubUrls(): Promise<GitHubUrls[] | null> {
7575
remote = [r.state.remotes[0]];
7676
}
7777

78-
if (
79-
remote.length > 0 &&
80-
(remote[0].pushUrl?.indexOf("github.com") !== -1 ||
81-
(useEnterprise() && remote[0].pushUrl?.indexOf(new URL(getGitHubApiUri()).host) !== -1))
82-
) {
83-
const url = remote[0].pushUrl;
84-
85-
return {
86-
workspaceUri: r.rootUri,
87-
url,
88-
protocol: new Protocol(url as string)
89-
};
78+
if (remote.length > 0 && remote[0].pushUrl) {
79+
const host = new URL(remote[0].pushUrl).host;
80+
const apiUri = new URL(getGitHubApiUri()).host;
81+
if (host === "github.com" || (useEnterprise() && host === apiUri)) {
82+
const url = remote[0].pushUrl;
83+
84+
return {
85+
workspaceUri: r.rootUri,
86+
url,
87+
protocol: new Protocol(url)
88+
};
89+
}
9090
}
9191

9292
logDebug(`Remote "${remoteName}" not found, skipping repository`);

0 commit comments

Comments
 (0)