From 2e8762744f261d56112db08efef89d9c1251d9ac Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 3 Dec 2011 12:43:38 +0100 Subject: [PATCH] Fix ComposerRepository ctor --- src/Composer/Repository/ComposerRepository.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index 57c19becd..f704c23ea 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -24,14 +24,17 @@ class ComposerRepository extends ArrayRepository protected $url; protected $packages; - public function __construct($url) + public function __construct(array $config) { - $url = rtrim($url, '/'); - if (!filter_var($url, FILTER_VALIDATE_URL)) { - throw new \UnexpectedValueException('Invalid url given for Composer repository: '.$url); + if (!preg_match('{^https?://}', $config['url'])) { + $config['url'] = 'http://'.$config['url']; + } + $config['url'] = rtrim($config['url'], '/'); + if (!filter_var($config['url'], FILTER_VALIDATE_URL)) { + throw new \UnexpectedValueException('Invalid url given for Composer repository: '.$config['url']); } - $this->url = $url; + $this->url = $config['url']; } protected function initialize()