Skip to content

Commit

Permalink
Feature: Allow local directory paths in repository of type composer
Browse files Browse the repository at this point in the history
Fixes: #11519
  • Loading branch information
helhum committed Jun 26, 2023
1 parent 2b18799 commit 30e047d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Composer/Repository/ComposerRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,13 @@ public function __construct(array $repoConfig, IOInterface $io, Config $config,
{
parent::__construct();
if (!Preg::isMatch('{^[\w.]+\??://}', $repoConfig['url'])) {
// assume http as the default protocol
$repoConfig['url'] = 'http://'.$repoConfig['url'];
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'] === '') {
Expand Down

0 comments on commit 30e047d

Please sign in to comment.