Skip to content

Commit 37a5969

Browse files
committed
fix: 🐛 improve robustness of release asset download logic
improve the robustness when downloading release assets for public repositories by using `browser_download_url` instead of `url`. FIXES: #116
1 parent ca6ba85 commit 37a5969

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/features/githubUtils.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,15 @@ export const grabReleaseFileFromRepository = async (
295295
Accept: "application/octet-stream",
296296
};
297297

298-
// Authenticated requests get a higher rate limit
299-
if ((isPrivate && personalAccessToken) || personalAccessToken) {
298+
// Authenticated requests get a higher rate limit, only needed for private repositories here
299+
if (isPrivate && personalAccessToken) {
300300
headers.Authorization = `Token ${personalAccessToken}`;
301301
}
302302

303+
// Download from the asset URL if it's a private repo, otherwise use the browser download URL
304+
const downloadUrl = isPrivate ? asset.url : asset.browser_download_url;
303305
const download = await request({
304-
url: asset.url,
306+
url: downloadUrl,
305307
headers,
306308
});
307309
return download === "Not Found" || download === `{"error":"Not Found"}` ? null : download;

0 commit comments

Comments
 (0)