aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Ai Hoshino <ambiguous404@gmail.com> 2023-09-18 19:32:02 +0800
committerGravatar GitHub <noreply@github.com> 2023-09-18 04:32:02 -0700
commitbab9889601eb13c01ebadb1f47752298259700b6 (patch)
tree8265ebd08295f01480d6b7576ceec6cb62e35fc6 /src
parentb27b04690b8746c4cd9aa0d066a7901a5bdf7e82 (diff)
downloadbun-bab9889601eb13c01ebadb1f47752298259700b6.tar.gz
bun-bab9889601eb13c01ebadb1f47752298259700b6.tar.zst
bun-bab9889601eb13c01ebadb1f47752298259700b6.zip
fix(config): support for registry url without trailing slash (#5662)
* fix(config): support for registry URLs without trailing slash Close: #4589, #5368 * Update src/bunfig.zig * Update src/bunfig.zig --------- Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Diffstat (limited to 'src')
-rw-r--r--src/bunfig.zig16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/bunfig.zig b/src/bunfig.zig
index 76f33cb82..bb52e3053 100644
--- a/src/bunfig.zig
+++ b/src/bunfig.zig
@@ -64,19 +64,27 @@ pub const Bunfig = struct {
// Token
if (url.username.len == 0 and url.password.len > 0) {
registry.token = url.password;
- registry.url = try std.fmt.allocPrint(this.allocator, "{s}://{s}/{s}", .{ url.displayProtocol(), url.displayHostname(), std.mem.trimLeft(u8, url.pathname, "/") });
+ registry.url = try std.fmt.allocPrint(this.allocator, "{s}://{s}/{s}/", .{ url.displayProtocol(), url.displayHostname(), std.mem.trim(u8, url.pathname, "/") });
} else if (url.username.len > 0 and url.password.len > 0) {
registry.username = url.username;
registry.password = url.password;
- registry.url = try std.fmt.allocPrint(this.allocator, "{s}://{s}/{s}", .{ url.displayProtocol(), url.displayHostname(), std.mem.trimLeft(u8, url.pathname, "/") });
+ registry.url = try std.fmt.allocPrint(this.allocator, "{s}://{s}/{s}/", .{ url.displayProtocol(), url.displayHostname(), std.mem.trim(u8, url.pathname, "/") });
} else {
- registry.url = url.href;
+ if (strings.hasSuffixComptime(url.href, "/")) {
+ registry.url = url.href;
+ } else {
+ registry.url = try std.fmt.allocPrint(this.allocator, "{s}/", .{url.href});
+ }
}
},
.e_object => |obj| {
if (obj.get("url")) |url| {
try this.expect(url, .e_string);
- registry.url = url.data.e_string.data;
+ if (strings.hasSuffixComptime(url.data.e_string.data, "/")) {
+ registry.url = url.data.e_string.data;
+ } else {
+ registry.url = try std.fmt.allocPrint(this.allocator, "{s}/", .{url.data.e_string.data});
+ }
}
if (obj.get("username")) |username| {