1
0
Fork 0

Feature: Allow local directory paths in repository of type composer (#11526)

Fixes: #11519
pull/11557/head
Helmut Hummel 2023-07-18 11:44:53 +02:00 committed by GitHub
parent 69746f699f
commit 68b7a07187
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -139,9 +139,14 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
{
parent::__construct();
if (!Preg::isMatch('{^[\w.]+\??://}', $repoConfig['url'])) {
// assume http as the default protocol
if (($localFilePath = realpath($repoConfig['url'])) !== false) {
// it is a local path, add file scheme
$repoConfig['url'] = 'file://'.$localFilePath;
} else {
// otherwise, assume http as the default protocol
$repoConfig['url'] = 'http://'.$repoConfig['url'];
}
}
$repoConfig['url'] = rtrim($repoConfig['url'], '/');
if ($repoConfig['url'] === '') {
throw new \InvalidArgumentException('The repository url must not be an empty string');