diff --git a/Converter/PackageUtil.php b/Converter/PackageUtil.php index ac819b36..c379afb1 100644 --- a/Converter/PackageUtil.php +++ b/Converter/PackageUtil.php @@ -25,6 +25,20 @@ */ abstract class PackageUtil { + /** + * @var string[] + */ + private static $extensions = array( + '.zip', + '.tar', + '.tar.gz', + '.tar.bz2', + '.tar.Z', + '.tar.xz', + '.bz2', + '.gz', + ); + /** * Checks if the version is a URL version. * @@ -41,7 +55,7 @@ public static function checkUrlVersion(AssetTypeInterface $assetType, $dependenc if (preg_match('/(\:\/\/)|\@/', $version)) { list($url, $version) = static::splitUrlVersion($version); - if (static::hasUrlDependencySupported($url)) { + if (!static::isUrlArchive($url) && static::hasUrlDependencySupported($url)) { $vcsRepos[] = array( 'type' => sprintf('%s-vcs', $assetType->getName()), 'url' => $url, @@ -67,6 +81,26 @@ public static function checkUrlVersion(AssetTypeInterface $assetType, $dependenc return array($dependency, $version); } + /** + * Check if the url is a url of a archive file. + * + * @param string $url The url + * + * @return bool + */ + public static function isUrlArchive($url) + { + if (0 === strpos($url, 'http')) { + foreach (self::$extensions as $extension) { + if (substr($url, -strlen($extension)) === $extension) { + return true; + } + } + } + + return false; + } + /** * Checks if the version is a alias version. * diff --git a/Tests/Converter/BowerPackageConverterTest.php b/Tests/Converter/BowerPackageConverterTest.php index ffd0cf83..36a4c717 100644 --- a/Tests/Converter/BowerPackageConverterTest.php +++ b/Tests/Converter/BowerPackageConverterTest.php @@ -72,6 +72,7 @@ public function testConvert() 'ASSET/test-library17-file' => '*', 'ASSET/test-library18-file' => '1.2.3', 'ASSET/test-library19-file' => '*', + 'ASSET/test-library20-file' => '*', ), $composer['require']); $this->assertArrayHasKey('require-dev', $composer); diff --git a/Tests/Converter/NpmPackageConverterTest.php b/Tests/Converter/NpmPackageConverterTest.php index a7625769..07c60595 100644 --- a/Tests/Converter/NpmPackageConverterTest.php +++ b/Tests/Converter/NpmPackageConverterTest.php @@ -82,7 +82,8 @@ public function testConvert() 'ASSET/test-library17-file' => '*', 'ASSET/test-library18-file' => '1.2.3', 'ASSET/test-library19-file' => '*', - 'ASSET/library20' => '1 || 2', + 'ASSET/test-library20-file' => '*', + 'ASSET/library21' => '1 || 2', ), $composer['require']); $this->assertArrayHasKey('require-dev', $composer); diff --git a/Tests/Fixtures/package/bower.json b/Tests/Fixtures/package/bower.json index 72b58bc7..18f7b7c9 100644 --- a/Tests/Fixtures/package/bower.json +++ b/Tests/Fixtures/package/bower.json @@ -34,7 +34,8 @@ "library16": "library16#>=1 <2", "library17": "http://foobar.tld/library17-1.2.3.js", "library18": "http://foobar.tld/library18.js#1.2.3", - "library19": "http://foobar.tld/library19.js" + "library19": "http://foobar.tld/library19.js", + "library20": "http://foobar.tld/library20/v1.2.tar.gz" }, "devDependencies": { "dev-library1": ">= 1.0.0", diff --git a/Tests/Fixtures/package/npm.json b/Tests/Fixtures/package/npm.json index 1a301546..fa5a0065 100644 --- a/Tests/Fixtures/package/npm.json +++ b/Tests/Fixtures/package/npm.json @@ -41,7 +41,8 @@ "library17": "http://foobar.tld/library17-1.2.3.js", "library18": "http://foobar.tld/library18.js#1.2.3", "library19": "http://foobar.tld/library19.js", - "library20": "1 || 2" + "library20": "http://foobar.tld/library20/v1.2.tar.gz", + "library21": "1 || 2" }, "devDependencies": { "dev-library1": ">= 1.0.0",