Skip to content

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.

fix(validation): update git:// URL validation to support port numbers and tilde characters in paths

Andras Bacsai502dd72a3443
diff --git a/app/Rules/ValidGitRepositoryUrl.php b/app/Rules/ValidGitRepositoryUrl.php
index 21509d65ac..ba1aed11b6 100644
--- a/app/Rules/ValidGitRepositoryUrl.php
+++ b/app/Rules/ValidGitRepositoryUrl.php
@@ -142,8 +142,8 @@ class ValidGitRepositoryUrl implements ValidationRule
return;
}
} elseif (str_starts_with($value, 'git://')) {
- // Validate git:// protocol URL
- if (! preg_match('/^git:\/\/[a-zA-Z0-9\.\-]+\/[a-zA-Z0-9\-_\/\.]+$/', $value)) {
+ // Validate git:// protocol URL (supports both git://host/path and git://host:port/path with tilde)
+ if (! preg_match('/^git:\/\/[a-zA-Z0-9\.\-]+(:[0-9]+)?[:\/][a-zA-Z0-9\-_\/\.~]+$/', $value)) {
$fail('The :attribute is not a valid git:// URL.');
return;
diff --git a/tests/Unit/ValidGitRepositoryUrlTest.php b/tests/Unit/ValidGitRepositoryUrlTest.php
index 12eb419f26..da467dc4d3 100644
--- a/tests/Unit/ValidGitRepositoryUrlTest.php
+++ b/tests/Unit/ValidGitRepositoryUrlTest.php
@@ -136,6 +136,7 @@ it('validates git:// protocol URLs', function () {
$validUrls = [
'git://github.com/user/repo.git',
'git://gitlab.com/user/repo.git',
+ 'git://git.sr.ht:~user/repo.git',
];
foreach ($validUrls as $url) {