From 007ca5ff6a4f837796c8e270f7b77a9183a0aed5 Mon Sep 17 00:00:00 2001 From: Minh-Quan TRAN Date: Tue, 12 Sep 2017 23:14:01 +0200 Subject: [PATCH] workaround for gitlab installation with relative url Signed-off-by: Minh-Quan TRAN --- src/Composer/Util/RemoteFilesystem.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php index 7b0d650bd..a9f788de0 100644 --- a/src/Composer/Util/RemoteFilesystem.php +++ b/src/Composer/Util/RemoteFilesystem.php @@ -195,6 +195,20 @@ class RemoteFilesystem $originUrl = 'github.com'; } + // Gitlab can be installed in a non-root context. When downloading archives the originalUrl is the host without + // the relative path, so we look for the registered gitlab-domains that matching the host here + if (is_array($this->config->get('gitlab-domains')) + && false === strpos($originUrl, '/') + && !in_array($originUrl, $this->config->get('gitlab-domains'))) { + foreach($this->config->get('gitlab-domains') as $gitlabDomain) { + if (0 === strpos($gitlabDomain, $originUrl)) { + $originUrl = $gitlabDomain; + break; + } + } + unset($gitlabDomain); + } + $this->scheme = parse_url($fileUrl, PHP_URL_SCHEME); $this->bytesMax = 0; $this->originUrl = $originUrl;