From 4130d388fe6d5dcf79971a18f4216a099855babe Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 11 Feb 2021 10:41:17 +0100 Subject: [PATCH] Auto-detect packagist.org default repo replacements and deactivate it if it is redefined --- src/Composer/Config.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Composer/Config.php b/src/Composer/Config.php index 436de79f2..7d904d8bd 100644 --- a/src/Composer/Config.php +++ b/src/Composer/Config.php @@ -78,8 +78,7 @@ class Config public static $defaultRepositories = array( 'packagist.org' => array( 'type' => 'composer', - 'url' => 'https?://repo.packagist.org', - 'allow_ssl_downgrade' => true, + 'url' => 'https://repo.packagist.org', ), ); @@ -182,6 +181,10 @@ class Config // store repo if (is_int($name)) { + // auto-deactivate the default packagist.org repo if it gets redefined + if (isset($repository['type'], $repository['url']) && $repository['type'] === 'composer' && preg_match('{^https?://(?:[a-z0-9-.]+\.)?packagist.org(/|$)}', $repository['url'])) { + $this->disableRepoByName('packagist.org'); + } $this->repositories[] = $repository; } else { if ($name === 'packagist') { // BC support for default "packagist" named repo