Skip to content

Commit d86be4f

Browse files
Merge pull request #107 from Seldaek/patch-1
Use the correct packagist.org domain for metadata routes
2 parents c74bfd1 + 4ea332a commit d86be4f

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828

2929
- name: Cache Composer packages
3030
id: composer-cache
31-
uses: actions/cache@v2
31+
uses: actions/cache@v4
3232
with:
3333
path: vendor
3434
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}

composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,10 @@
4141
"scripts": {
4242
"lint": "vendor/bin/phpcs --standard=PSR12 src/",
4343
"test": "vendor/bin/phpspec run -f pretty"
44+
},
45+
"config": {
46+
"allow-plugins": {
47+
"php-http/discovery": true
48+
}
4449
}
4550
}

spec/Packagist/Api/ClientSpec.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@ public function it_gets_composer_package_details(HttpClient $client, Factory $fa
106106
$response->getBody()->shouldBeCalled()->willReturn($body);
107107
$body->getContents()->shouldBeCalledTimes(2)->willReturn($data1, $data2);
108108

109-
$client->request('GET', 'https://packagist.org/p2/sylius/sylius.json')
109+
$client->request('GET', 'https://repo.packagist.org/p2/sylius/sylius.json')
110110
->shouldBeCalled()
111111
->willReturn($response);
112112

113-
$client->request('GET', 'https://packagist.org/p2/sylius/sylius~dev.json')
113+
$client->request('GET', 'https://repo.packagist.org/p2/sylius/sylius~dev.json')
114114
->shouldBeCalled()
115115
->willReturn($response);
116116

@@ -140,7 +140,7 @@ public function it_gets_composer_releases_package_details(HttpClient $client, Fa
140140
$response->getBody()->shouldBeCalled()->willReturn($body);
141141
$body->getContents()->shouldBeCalled()->willReturn($data);
142142

143-
$client->request('GET', 'https://packagist.org/p2/sylius/sylius.json')
143+
$client->request('GET', 'https://repo.packagist.org/p2/sylius/sylius.json')
144144
->shouldBeCalled()
145145
->willReturn($response);
146146

src/Packagist/Api/Client.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,10 @@ private function filterAdvisories(array $advisories, array $packages): array
287287
*/
288288
protected function url(string $route): string
289289
{
290+
if (preg_match('{^/p\d?/}', $route) && $this->packagistUrl === 'https://packagist.org') {
291+
return 'https://repo.packagist.org' . $route;
292+
}
293+
290294
return $this->packagistUrl . $route;
291295
}
292296

0 commit comments

Comments
 (0)