fix(git): harden ssh URL normalization

This commit is contained in:
Iisyourdad
2026-04-07 22:41:15 -05:00
parent f877985e56
commit d2ada90a47
2 changed files with 41 additions and 3 deletions
+36
View File
@@ -68,3 +68,39 @@ test('convertGitUrlsForSourceAndSshUrlSchemeWithCustomPort', function () {
'port' => '22222',
]);
});
test('convertGitUrlsForSourceAndSshUrlSchemeWithCustomPortAndIpv6Host', function () {
$result = convertGitUrl('ssh://git@[2001:db8::10]:22222/group/project.git', 'source', null);
expect($result)->toBe([
'repository' => 'ssh://git@[2001:db8::10]:22222/group/project.git',
'port' => '22222',
]);
});
test('convertGitUrlsForDeployKeyAndGithubAppWithCustomPort', function () {
$githubApp = new GithubApp([
'html_url' => 'https://github.example.com',
'custom_user' => 'git',
'custom_port' => 22222,
]);
$result = convertGitUrl('andrasbacsai/coolify-examples.git', 'deploy_key', $githubApp);
expect($result)->toBe([
'repository' => 'ssh://git@github.example.com:22222/andrasbacsai/coolify-examples.git',
'port' => '22222',
]);
});
test('convertGitUrlsForDeployKeyAndGithubAppWithCustomPortAndIpv6Host', function () {
$githubApp = new GithubApp([
'html_url' => 'https://[2001:db8::10]',
'custom_user' => 'git',
'custom_port' => 22222,
]);
$result = convertGitUrl('andrasbacsai/coolify-examples.git', 'deploy_key', $githubApp);
expect($result)->toBe([
'repository' => 'ssh://git@[2001:db8::10]:22222/andrasbacsai/coolify-examples.git',
'port' => '22222',
]);
});