handle trailing slash

This commit is contained in:
Emil Lerch 2025-07-20 15:24:14 -07:00
parent 981a46da54
commit 22f24c1ddb
Signed by: lobo
GPG key ID: A7B62D657EF764F8

View file

@ -83,8 +83,14 @@ fn getStarredRepos(allocator: Allocator, client: *http.Client, base_url: []const
var page: u32 = 1; var page: u32 = 1;
const per_page: u32 = 100; const per_page: u32 = 100;
// Normalize base_url by removing trailing slash if present
const normalized_base_url = if (std.mem.endsWith(u8, base_url, "/"))
base_url[0 .. base_url.len - 1]
else
base_url;
while (true) { while (true) {
const url = try std.fmt.allocPrint(allocator, "{s}/api/v1/user/starred?limit={d}&page={d}", .{ base_url, per_page, page }); const url = try std.fmt.allocPrint(allocator, "{s}/api/v1/user/starred?limit={d}&page={d}", .{ normalized_base_url, per_page, page });
defer allocator.free(url); defer allocator.free(url);
const uri = try std.Uri.parse(url); const uri = try std.Uri.parse(url);