Skip to content

Commit 71e2fda

Browse files
committed
Improves handling of git repos with a prefix
1 parent eb24983 commit 71e2fda

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/Service/RecipePublicUrlResolver.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,16 @@ private function resolveHttpUrl(string $repoUrl, string $packageName)
7373
*/
7474
private function resolveSshUrl(string $repoUrl, string $packageName)
7575
{
76-
if (preg_match('/^(?:ssh(?:\:\/\/)?)?(?:git)?\@?([a-zA-Z0-9-_\.]+\.[a-z]+)[:\/](?:([0-9]+)(?:\/))?([a-zA-Z0-9-_\.]+)\/([a-zA-Z0-9-_]+)(?:\.git)?$/', $repoUrl, $urlParts)) {
76+
if (preg_match('/^(?:ssh(?::\/\/)?)?(?:git)?@?([a-zA-Z0-9-_\.]+\.[a-z]+)(:[0-9])?(?:[:\/]([a-zA-Z0-9-_\.]*))?\/([a-zA-Z0-9-_\.]+)\/([a-zA-Z0-9-_]+)(?:.git)?$/', $repoUrl, $urlParts)) {
7777
$host = $urlParts[1];
7878
$port = empty($urlParts[2]) ? null : $urlParts[2];
79-
$user = $urlParts[3];
80-
$repo = $urlParts[4];
79+
$prefix = empty($urlParts[3]) ? null : $urlParts[3];
80+
$user = $urlParts[4];
81+
$repo = $urlParts[5];
82+
83+
if (null !== $prefix) {
84+
return $this->buildUrl($host, implode('/', [$prefix, $user, $repo]), $packageName, $port);
85+
}
8186

8287
return $this->buildUrl($host, implode('/', [$user, $repo]), $packageName, $port);
8388
}

0 commit comments

Comments
 (0)