fix(git): exclude SSH ports from provider URLs (#12537)

This commit is contained in:
Anton Bezdenezhnykh authored and GitHub committed 2026-09-25 23:14:20 -05:00
1 parent dd8332da57
commit 29a32660d3
2 files changed
+23 -1

No files matched your search

+6 -1
View File
@@ -146,6 +146,10 @@ export function isSshRemoteUrl(remoteUrl: string): boolean {
return SCP_SSH_REMOTE_PATTERN.test(trimmed) || trimmed.toLowerCase().startsWith("ssh://");
}
/**
* Extracts the normalized host used for provider detection. SCP-style and SSH remotes return the
* hostname only, while other URL schemes retain explicit ports for non-default web endpoints.
*/
function parseRemoteHost(remoteUrl: string): string | null {
const trimmed = remoteUrl.trim();
if (trimmed.length === 0) {
@@ -158,7 +162,8 @@ function parseRemoteHost(remoteUrl: string): string | null {
}
try {
return new URL(trimmed).host.toLowerCase();
const url = new URL(trimmed);
return (url.protocol === "ssh:" ? url.hostname : url.host).toLowerCase();
} catch {
return null;
}