From 832d6580737967ea3cc5b29f25b68ee0574a0337 Mon Sep 17 00:00:00 2001 From: Michiel Vermeersch Date: Mon, 14 Oct 2024 14:27:12 +0200 Subject: [PATCH] Fixed getReleaseAssetsForPackage() for repositories with names that do not match the package name. --- src/Downloading/GithubPackageReleaseAssets.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Downloading/GithubPackageReleaseAssets.php b/src/Downloading/GithubPackageReleaseAssets.php index eaf1d1d..5475f1d 100644 --- a/src/Downloading/GithubPackageReleaseAssets.php +++ b/src/Downloading/GithubPackageReleaseAssets.php @@ -76,9 +76,16 @@ private function selectMatchingReleaseAsset(TargetPlatform $targetPlatform, Pack /** @return list */ private function getReleaseAssetsForPackage(Package $package): array { - // @todo confirm prettyName will always match the repo name - it might not + if (($download = $package->downloadUrl) !== null && !str_contains($download, $package->name)) { + // Converts https://api.github.com/repos///zipball/" to "/" + $path = parse_url($download)['path']; + $name = implode('/', array_slice(explode('/', $path), 2, 2)); + } else { + $name = $package->name; + } + $request = AddAuthenticationHeader::withAuthHeaderFromComposer( - new Request('GET', $this->githubApiBaseUrl . '/repos/' . $package->name . '/releases/tags/' . $package->version), + new Request('GET', $this->githubApiBaseUrl . '/repos/' . $name . '/releases/tags/' . $package->version), $package, $this->authHelper, );