diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a8287ed..f5ce90a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,7 +28,7 @@ jobs: - name: Cache Composer packages id: composer-cache - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: vendor key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} diff --git a/composer.json b/composer.json index bb87705..aa9d3d8 100644 --- a/composer.json +++ b/composer.json @@ -41,5 +41,10 @@ "scripts": { "lint": "vendor/bin/phpcs --standard=PSR12 src/", "test": "vendor/bin/phpspec run -f pretty" + }, + "config": { + "allow-plugins": { + "php-http/discovery": true + } } } diff --git a/spec/Packagist/Api/ClientSpec.php b/spec/Packagist/Api/ClientSpec.php index c4b590d..972f10d 100644 --- a/spec/Packagist/Api/ClientSpec.php +++ b/spec/Packagist/Api/ClientSpec.php @@ -106,11 +106,11 @@ public function it_gets_composer_package_details(HttpClient $client, Factory $fa $response->getBody()->shouldBeCalled()->willReturn($body); $body->getContents()->shouldBeCalledTimes(2)->willReturn($data1, $data2); - $client->request('GET', 'https://packagist.org/p2/sylius/sylius.json') + $client->request('GET', 'https://repo.packagist.org/p2/sylius/sylius.json') ->shouldBeCalled() ->willReturn($response); - $client->request('GET', 'https://packagist.org/p2/sylius/sylius~dev.json') + $client->request('GET', 'https://repo.packagist.org/p2/sylius/sylius~dev.json') ->shouldBeCalled() ->willReturn($response); @@ -140,7 +140,7 @@ public function it_gets_composer_releases_package_details(HttpClient $client, Fa $response->getBody()->shouldBeCalled()->willReturn($body); $body->getContents()->shouldBeCalled()->willReturn($data); - $client->request('GET', 'https://packagist.org/p2/sylius/sylius.json') + $client->request('GET', 'https://repo.packagist.org/p2/sylius/sylius.json') ->shouldBeCalled() ->willReturn($response); diff --git a/src/Packagist/Api/Client.php b/src/Packagist/Api/Client.php index 7ada102..4788f65 100644 --- a/src/Packagist/Api/Client.php +++ b/src/Packagist/Api/Client.php @@ -287,6 +287,10 @@ private function filterAdvisories(array $advisories, array $packages): array */ protected function url(string $route): string { + if (preg_match('{^/p\d?/}', $route) && $this->packagistUrl === 'https://packagist.org') { + return 'https://repo.packagist.org' . $route; + } + return $this->packagistUrl . $route; }