aboutsummaryrefslogtreecommitdiff
path: root/src/install/install.zig
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-07-22 17:12:37 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-07-22 17:12:37 -0700
commit849c743cd2e5e9a2cbde1b3be519eab49239cea2 (patch)
treeaa4d8f30c0625a3863938725184edd46c7a1ef79 /src/install/install.zig
parent52144c057793cb38e18645ad0e93247f5fd9f2ac (diff)
downloadbun-849c743cd2e5e9a2cbde1b3be519eab49239cea2.tar.gz
bun-849c743cd2e5e9a2cbde1b3be519eab49239cea2.tar.zst
bun-849c743cd2e5e9a2cbde1b3be519eab49239cea2.zip
[bun install] Fix issue with URL path when sending request
Diffstat (limited to '')
-rw-r--r--src/install/install.zig56
1 files changed, 55 insertions, 1 deletions
diff --git a/src/install/install.zig b/src/install/install.zig
index 6c00ffe76..7373cf90d 100644
--- a/src/install/install.zig
+++ b/src/install/install.zig
@@ -199,7 +199,61 @@ const NetworkTask = struct {
scope: *const Npm.Registry.Scope,
loaded_manifest: ?Npm.PackageManifest,
) !void {
- this.url_buf = try std.fmt.allocPrint(allocator, "{s}://{s}:{d}/{s}/{s}", .{ scope.url.displayProtocol(), scope.url.displayHostname(), scope.url.getPortAuto(), strings.trim(scope.url.path, "/"), name });
+ const pathname: string = if (!strings.eqlComptime(scope.url.pathname, "/"))
+ scope.url.pathname
+ else
+ @as(string, "");
+
+ if (pathname.len > 0) {
+ if (scope.url.getPort()) |port_number| {
+ this.url_buf = try std.fmt.allocPrint(
+ allocator,
+ "{s}://{s}:{d}/{s}/{s}",
+ .{
+ scope.url.displayProtocol(),
+ scope.url.displayHostname(),
+ port_number,
+ pathname,
+ name,
+ },
+ );
+ } else {
+ this.url_buf = try std.fmt.allocPrint(
+ allocator,
+ "{s}://{s}/{s}/{s}",
+ .{
+ scope.url.displayProtocol(),
+ scope.url.displayHostname(),
+ pathname,
+ name,
+ },
+ );
+ }
+ } else {
+ if (scope.url.getPort()) |port_number| {
+ this.url_buf = try std.fmt.allocPrint(
+ allocator,
+ "{s}://{s}:{d}/{s}",
+ .{
+ scope.url.displayProtocol(),
+ scope.url.displayHostname(),
+ port_number,
+ name,
+ },
+ );
+ } else {
+ this.url_buf = try std.fmt.allocPrint(
+ allocator,
+ "{s}://{s}/{s}",
+ .{
+ scope.url.displayProtocol(),
+ scope.url.displayHostname(),
+ name,
+ },
+ );
+ }
+ }
+
var last_modified: string = "";
var etag: string = "";
if (loaded_manifest) |manifest| {