Skip to content

Commit 41d48c2

Browse files
authored
Copy GitHub Permalink doesn't work for GitHub Managed User (ghe.com) (#7493)
Fixes #7389
1 parent 0d7e58b commit 41d48c2

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

src/issues/util.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { URL } from 'url';
76
import LRUCache from 'lru-cache';
87
import 'url-search-params-polyfill';
98
import * as vscode from 'vscode';
@@ -365,22 +364,9 @@ export function getUpstreamOrigin(upstream: Remote, resultHost: string = 'github
365364
const enterpriseUri = getEnterpriseUri();
366365
let fetchUrl = upstream.fetchUrl;
367366
if (enterpriseUri && fetchUrl) {
368-
// upstream's origin by https
369-
if (fetchUrl.startsWith('https://') && !fetchUrl.startsWith('https://github.com/')) {
370-
const host = new URL(fetchUrl).host;
371-
if (host.startsWith(enterpriseUri.authority) || !host.includes('github.com')) {
372-
resultHost = enterpriseUri.authority;
373-
}
374-
}
375-
if (fetchUrl.startsWith('ssh://')) {
376-
fetchUrl = fetchUrl.substr('ssh://'.length);
377-
}
378-
// upstream's origin by ssh
379-
if ((fetchUrl.startsWith('git@') || fetchUrl.includes('@git')) && !fetchUrl.startsWith('[email protected]')) {
380-
const host = fetchUrl.split('@')[1]?.split(':')[0];
381-
if (host.startsWith(enterpriseUri.authority) || !host.includes('github.com')) {
382-
resultHost = enterpriseUri.authority;
383-
}
367+
const protocol = new Protocol(fetchUrl);
368+
if (protocol.host.startsWith(enterpriseUri.authority) || !protocol.host.includes('github.com')) {
369+
resultHost = enterpriseUri.authority;
384370
}
385371
}
386372
return `https://${resultHost}`;

0 commit comments

Comments
 (0)