diff --git a/src/Composer/Package/Package.php b/src/Composer/Package/Package.php index 9223fba93..300c5ef03 100644 --- a/src/Composer/Package/Package.php +++ b/src/Composer/Package/Package.php @@ -623,11 +623,16 @@ class Package extends BasePackage if (!$url) { return array(); } + + if ($urlType === 'dist' && false !== strpos($url, '%')) { + $url = ComposerMirror::processUrl($url, $this->name, $this->version, $ref, $type, $this->prettyVersion); + } + $urls = array($url); if ($mirrors) { foreach ($mirrors as $mirror) { if ($urlType === 'dist') { - $mirrorUrl = ComposerMirror::processUrl($mirror['url'], $this->name, $this->version, $ref, $type); + $mirrorUrl = ComposerMirror::processUrl($mirror['url'], $this->name, $this->version, $ref, $type, $this->prettyVersion); } elseif ($urlType === 'source' && $type === 'git') { $mirrorUrl = ComposerMirror::processGitUrl($mirror['url'], $this->name, $url, $type); } elseif ($urlType === 'source' && $type === 'hg') { diff --git a/src/Composer/Util/ComposerMirror.php b/src/Composer/Util/ComposerMirror.php index 036444d20..c73a2702c 100644 --- a/src/Composer/Util/ComposerMirror.php +++ b/src/Composer/Util/ComposerMirror.php @@ -19,18 +19,21 @@ namespace Composer\Util; */ class ComposerMirror { - public static function processUrl($mirrorUrl, $packageName, $version, $reference, $type) + public static function processUrl($mirrorUrl, $packageName, $version, $reference, $type, $prettyVersion = null) { if ($reference) { $reference = preg_match('{^([a-f0-9]*|%reference%)$}', $reference) ? $reference : md5($reference); } $version = strpos($version, '/') === false ? $version : md5($version); - return str_replace( - array('%package%', '%version%', '%reference%', '%type%'), - array($packageName, $version, $reference, $type), - $mirrorUrl - ); + $from = array('%package%', '%version%', '%reference%', '%type%'); + $to = array($packageName, $version, $reference, $type); + if (null !== $prettyVersion) { + $from[] = '%prettyVersion%'; + $to[] = $prettyVersion; + } + + return str_replace($from, $to, $mirrorUrl); } public static function processGitUrl($mirrorUrl, $packageName, $url, $type)