An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
<?php
it('parses scp-style ssh git urls including custom usernames and ports', function (string $url, array $expected) {
expect(parseScpStyleGitUrl($url))->toBe($expected);
})->with([
'git username' => [
'[email protected]:organization/repository.git',
[
'user' => 'git',
'host' => 'github.com',
'port' => null,
'path' => 'organization/repository.git',
],
],
'custom username' => [
'[email protected]:organization/repository.git',
[
'user' => 'custom-user',
'host' => 'git.example.com',
'port' => null,
'path' => 'organization/repository.git',
],
],
'custom username and port' => [
'[email protected]:2222/organization/repository.git',
[
'user' => 'custom-user',
'host' => 'git.example.com',
'port' => '2222',
'path' => 'organization/repository.git',
],
],
'IPv6 host' => [
'git@[2a01:4f8::1]:organization/repository.git',
[
'user' => 'git',
'host' => '[2a01:4f8::1]',
'port' => null,
'path' => 'organization/repository.git',
],
],
'IPv6 host and port' => [
'git@[fd00::5]:2222/organization/repository.git',
[
'user' => 'git',
'host' => '[fd00::5]',
'port' => '2222',
'path' => 'organization/repository.git',
],
],
]);
it('converts ssh git urls to https without embedding custom ports in the path', function (string $url, string $expected) {
expect(sshGitUrlToHttps($url))->toBe($expected);
})->with([
'git username' => [
'[email protected]:organization/repository.git',
'https://github.com/organization/repository.git',
],
'custom username' => [
'[email protected]:organization/repository.git',
'https://git.example.com/organization/repository.git',
],
'custom username and port' => [
'[email protected]:2222/organization/repository.git',
'https://git.example.com/organization/repository.git',
],
'IPv6 host and port' => [
'git@[fd00::5]:2222/organization/repository.git',
'https://[fd00::5]/organization/repository.git',
],
'ssh scheme' => [
'ssh://[email protected]/organization/repository.git',
'https://github.com/organization/repository.git',
],
'ssh scheme with port' => [
'ssh://[email protected]:2222/organization/repository.git',
'https://gitea.example.com/organization/repository.git',
],
'ssh scheme with IPv6 host and port' => [
'ssh://git@[fd00::5]:2222/organization/repository.git',
'https://[fd00::5]/organization/repository.git',
],
]);
it('rejects non-scp-style git urls', function (string $url) {
expect(parseScpStyleGitUrl($url))->toBeNull()
->and(sshGitUrlToHttps($url))->toBeNull();
})->with([
'https' => 'https://github.com/organization/repository.git',
'email without path' => '[email protected]',
'empty' => '',
]);
it('normalizes github app repository slugs from ssh urls', function (string $url, string $expected) {
expect(gitRepositorySlug($url))->toBe($expected);
})->with([
'https' => ['https://github.com/organization/repository.git', 'organization/repository'],
'owner/repo' => ['organization/repository', 'organization/repository'],
'git username' => ['[email protected]:organization/repository.git', 'organization/repository'],
'custom username' => ['[email protected]:organization/repository.git', 'organization/repository'],
'custom username and port' => ['[email protected]:2222/organization/repository.git', 'organization/repository'],
'ssh scheme' => ['ssh://[email protected]/organization/repository.git', 'organization/repository'],
'ssh scheme with port' => ['ssh://[email protected]:2222/organization/repository.git', 'organization/repository'],
]);