Skip to content

Commit 6ae8879

Browse files
Set a default urlpath if it is not returned by the API (fixes #6)
1 parent 2e1761f commit 6ae8879

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/aur.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,18 @@ static int json_end_map (void *ctx)
304304
pkg_json->level -= 1;
305305
if (pkg_json->level == 1 && pkg_json->pkg != NULL)
306306
{
307+
// If the urlpath isn't given by the API, build it based on the name. This fixes
308+
// a compatibility issue between AUR v3 and v4 APIs.
309+
if (aur_pkg_get_urlpath(pkg_json->pkg) == NULL)
310+
{
311+
const char *name = aur_pkg_get_name(pkg_json->pkg);
312+
if (name != NULL) {
313+
size_t size = strnlen(name, 200) + 34;
314+
pkg_json->pkg->urlpath = malloc(sizeof(char) * size);
315+
snprintf(pkg_json->pkg->urlpath, size, "/cgit/%s.git/snapshot/master.tar.gz", name);
316+
}
317+
}
318+
307319
switch (config.sort)
308320
{
309321
case S_VOTE:

0 commit comments

Comments
 (0)