From 12982134e8d8b4e6932ac5c4a3f1bf1119df9515 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Mon, 27 Jan 2025 17:36:13 +0000 Subject: [PATCH] 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 --- src/pakfire/xfer.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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) { -- 2.47.3