Skip to content

Commit a573900

Browse files
committed
Use default endopoints as fallbacks if Composer endpoint is specified as a string
1 parent f05406b commit a573900

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Downloader.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,17 @@ public function __construct(Composer $composer, IoInterface $io, $rfs)
5959
if (null === $endpoint = $composer->getPackage()->getExtra()['symfony']['endpoint'] ?? null) {
6060
$this->endpoints = self::DEFAULT_ENDPOINTS;
6161

62-
if (!filter_var(getenv('FLEX_SERVERLESS'), \FILTER_VALIDATE_BOOLEAN)) {
62+
if (!$this->isServerlessEnabled()) {
6363
$this->endpoints = null;
6464
$this->legacyEndpoint = 'https://flex.symfony.com';
6565
}
6666
} elseif (\is_array($endpoint) || false !== strpos($endpoint, '.json') || 'flex://defaults' === $endpoint) {
6767
$this->endpoints = array_values((array) $endpoint);
68+
if (false !== strpos($endpoint, '.json')) {
69+
$this->endpoints[] = 'flex://defaults';
70+
}
71+
} elseif ($this->isServerlessEnabled() && \is_string($endpoint)) {
72+
$this->endpoints = [$endpoint, 'flex://defaults'];
6873
} else {
6974
$this->legacyEndpoint = rtrim($endpoint, '/');
7075
}
@@ -414,4 +419,9 @@ private function initialize()
414419
$this->endpoints[$endpoint] = $config;
415420
}
416421
}
422+
423+
private function isServerlessEnabled(): bool
424+
{
425+
return filter_var(getenv('FLEX_SERVERLESS'), \FILTER_VALIDATE_BOOLEAN);
426+
}
417427
}

0 commit comments

Comments
 (0)