diff --git a/src/Composer/Package/Package.php b/src/Composer/Package/Package.php index 300c5ef03..1f1cdf553 100644 --- a/src/Composer/Package/Package.php +++ b/src/Composer/Package/Package.php @@ -594,7 +594,10 @@ class Package extends BasePackage // only bitbucket, github and gitlab have auto generated dist URLs that easily allow replacing the reference in the dist URL // TODO generalize this a bit for self-managed/on-prem versions? Some kind of replace token in dist urls which allow this? - if (preg_match('{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com|(?:www\.)?gitlab\.com)/}i', $this->getDistUrl())) { + if ( + $this->getDistUrl() !== null + && preg_match('{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com|(?:www\.)?gitlab\.com)/}i', $this->getDistUrl()) + ) { $this->setDistReference($reference); $this->setDistUrl(preg_replace('{(?<=/|sha=)[a-f0-9]{40}(?=/|$)}i', $reference, $this->getDistUrl())); } elseif ($this->getDistReference()) { // update the dist reference if there was one, but if none was provided ignore it