|
3 | 3 | * Licensed under the MIT License. See License.txt in the project root for license information. |
4 | 4 | *--------------------------------------------------------------------------------------------*/ |
5 | 5 |
|
6 | | -import { URL } from 'url'; |
7 | 6 | import LRUCache from 'lru-cache'; |
8 | 7 | import 'url-search-params-polyfill'; |
9 | 8 | import * as vscode from 'vscode'; |
@@ -365,22 +364,9 @@ export function getUpstreamOrigin(upstream: Remote, resultHost: string = 'github |
365 | 364 | const enterpriseUri = getEnterpriseUri(); |
366 | 365 | let fetchUrl = upstream.fetchUrl; |
367 | 366 | 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('git@github.com')) { |
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; |
384 | 370 | } |
385 | 371 | } |
386 | 372 | return `https://${resultHost}`; |
|
0 commit comments