fix(validation): update git:// URL validation to support port numbers and tilde characters in paths
This commit is contained in:
parent
a8bdc3bbfe
commit
502dd72a34
2 changed files with 3 additions and 2 deletions
|
|
@ -142,8 +142,8 @@ public function validate(string $attribute, mixed $value, Closure $fail): void
|
|||
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;
|
||||
|
|
|
|||
|
|
@ -136,6 +136,7 @@
|
|||
$validUrls = [
|
||||
'git://github.com/user/repo.git',
|
||||
'git://gitlab.com/user/repo.git',
|
||||
'git://git.sr.ht:~user/repo.git',
|
||||
];
|
||||
|
||||
foreach ($validUrls as $url) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue