diff options
author | 2023-07-30 04:03:48 -0700 | |
---|---|---|
committer | 2023-07-30 04:04:06 -0700 | |
commit | a9dc5d51e3de0f1dc5d20a12243fd4dbe536bff4 (patch) | |
tree | bdc465afd0b2e8b6b55f18c9c958d969334d01ae | |
parent | 749194378a0ceae184d85eda9a170fd821e8d730 (diff) | |
download | bun-a9dc5d51e3de0f1dc5d20a12243fd4dbe536bff4.tar.gz bun-a9dc5d51e3de0f1dc5d20a12243fd4dbe536bff4.tar.zst bun-a9dc5d51e3de0f1dc5d20a12243fd4dbe536bff4.zip |
Fixes #3884
-rw-r--r-- | src/install/install.zig | 47 | ||||
-rw-r--r-- | src/install/npm.zig | 2 |
2 files changed, 7 insertions, 42 deletions
diff --git a/src/install/install.zig b/src/install/install.zig index 74904b276..2d5edacde 100644 --- a/src/install/install.zig +++ b/src/install/install.zig @@ -4475,23 +4475,7 @@ pub const PackageManager = struct { for (scoped.scopes, 0..) |name, i| { var registry = scoped.registries[i]; if (registry.url.len == 0) registry.url = base.url; - try this.registries.put(allocator, Npm.Registry.Scope.hash(name), Npm.Registry.Scope.fromAPI(name, registry, allocator, env) catch |err| { - if (err == error.InvalidURL) { - log.addErrorFmt( - null, - logger.Loc.Empty, - allocator, - "{} is not a valid registry URL", - .{ - strings.QuotedFormatter{ - .text = registry.url, - }, - }, - ) catch unreachable; - } - - return err; - }); + try this.registries.put(allocator, Npm.Registry.Scope.hash(name), try Npm.Registry.Scope.fromAPI(name, registry, allocator, env)); } } @@ -4604,21 +4588,10 @@ pub const PackageManager = struct { { const prev_scope = this.scope; var api_registry = std.mem.zeroes(Api.NpmRegistry); - var href = bun.JSC.URL.hrefFromString(bun.String.fromUTF8(registry_)); - if (href.tag == .Dead) { - try log.addErrorFmt(null, logger.Loc.Empty, bun.default_allocator, "${s} has invalid URL {}", .{ - registry_key, strings.QuotedFormatter{ - .text = registry_, - }, - }); - } else { - defer href.deref(); - - api_registry.token = prev_scope.token; - this.scope = try Npm.Registry.Scope.fromAPI("", api_registry, allocator, env); - api_registry.url = try href.toOwnedSlice(bun.default_allocator); - did_set = true; - } + api_registry.url = registry_; + api_registry.token = prev_scope.token; + this.scope = try Npm.Registry.Scope.fromAPI("", api_registry, allocator, env); + did_set = true; } } } @@ -4651,15 +4624,7 @@ pub const PackageManager = struct { if (cli.registry.len > 0 and strings.startsWith(cli.registry, "https://") or strings.startsWith(cli.registry, "http://")) { - if (URL.fromUTF8(instance.allocator, cli.registry)) |url| { - this.scope.url = url; - } else |_| { - try log.addErrorFmt(null, logger.Loc.Empty, bun.default_allocator, "--registry has invalid URL {}", .{ - strings.QuotedFormatter{ - .text = cli.registry, - }, - }); - } + this.scope.url = URL.parse(cli.registry); } if (cli.exact) { diff --git a/src/install/npm.zig b/src/install/npm.zig index b135a9548..0a25fe636 100644 --- a/src/install/npm.zig +++ b/src/install/npm.zig @@ -68,7 +68,7 @@ pub const Registry = struct { pub fn fromAPI(name: string, registry_: Api.NpmRegistry, allocator: std.mem.Allocator, env: *DotEnv.Loader) !Scope { var registry = registry_; - var url = try URL.fromUTF8(bun.default_allocator, registry.url); + var url = URL.parse(registry.url); var auth: string = ""; if (registry.token.len == 0) { |