From 68b7a07187a62435e514324052d5a649b6662efb Mon Sep 17 00:00:00 2001 From: Helmut Hummel Date: Tue, 18 Jul 2023 11:44:53 +0200 Subject: [PATCH] Feature: Allow local directory paths in repository of type composer (#11526) Fixes: #11519 --- src/Composer/Repository/ComposerRepository.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index ea87e5c4b..0efb02e96 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -139,8 +139,13 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito { 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'] === '') {