From: Michael Tremer Date: Mon, 27 Jan 2025 17:36:13 +0000 (+0000) Subject: xfer: Always append a / to the base URL X-Git-Tag: 0.9.30~333 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12982134e8d8b4e6932ac5c4a3f1bf1119df9515;p=pakfire.git xfer: Always append a / to the base URL When cURL merges URLs it will cut off the last part if the URL is not terminated with /. Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/xfer.c b/src/pakfire/xfer.c index 32af2f57..454c533a 100644 --- a/src/pakfire/xfer.c +++ b/src/pakfire/xfer.c @@ -497,7 +497,21 @@ int pakfire_xfer_set_title(struct pakfire_xfer* xfer, const char* title) { } int pakfire_xfer_set_baseurl(struct pakfire_xfer* xfer, const char* baseurl) { - return pakfire_string_set(xfer->baseurl, baseurl); + int r; + + // Store the URL + r = pakfire_string_set(xfer->baseurl, baseurl); + if (r < 0) + return r; + + // If the URL does not end with a /, let's add it + if (!pakfire_string_endswith(xfer->baseurl, "/")) { + r = pakfire_string_append(xfer->baseurl, "/"); + if (r < 0) + return r; + } + + return 0; } const char* pakfire_xfer_get_effective_url(struct pakfire_xfer* xfer) {