diff --git a/src/Composer/Downloader/FileDownloader.php b/src/Composer/Downloader/FileDownloader.php index 28dd2d779..ddde199b6 100644 --- a/src/Composer/Downloader/FileDownloader.php +++ b/src/Composer/Downloader/FileDownloader.php @@ -88,8 +88,7 @@ class FileDownloader implements DownloaderInterface $urls = $package->getDistUrls(); while ($url = array_shift($urls)) { try { - $this->doDownload($package, $path, $url); - break; + return $this->doDownload($package, $path, $url); } catch (\Exception $e) { if ($this->io->isDebug()) { $this->io->write(''); diff --git a/src/Composer/Package/Package.php b/src/Composer/Package/Package.php index ffc759f62..970068cd2 100644 --- a/src/Composer/Package/Package.php +++ b/src/Composer/Package/Package.php @@ -13,6 +13,7 @@ namespace Composer\Package; use Composer\Package\Version\VersionParser; +use Composer\Util\ComposerMirror; /** * Core package definitions that are needed to resolve dependencies and install packages @@ -581,14 +582,13 @@ class Package extends BasePackage protected function getUrls($url, $mirrors, $ref, $type) { - $urls = array($url); + $urls = array(); + if ($url) { + $urls[] = $url; + } if ($mirrors) { foreach ($mirrors as $mirror) { - $mirrorUrl = str_replace( - array('%package%', '%version%', '%reference%', '%type%'), - array($this->name, $this->version, $ref, $type), - $mirror['url'] - ); + $mirrorUrl = ComposerMirror::processUrl($mirror['url'], $this->name, $this->version, $ref, $type); $func = $mirror['preferred'] ? 'array_unshift' : 'array_push'; $func($urls, $mirrorUrl); } diff --git a/src/Composer/Util/ComposerMirror.php b/src/Composer/Util/ComposerMirror.php new file mode 100644 index 000000000..710f52cce --- /dev/null +++ b/src/Composer/Util/ComposerMirror.php @@ -0,0 +1,33 @@ +