mirror of
https://github.com/oven-sh/bun
synced 2026-02-16 13:51:47 +00:00
Move emptiness check to hasValidPort
This commit is contained in:
@@ -2241,7 +2241,7 @@ pub const Fetch = struct {
|
||||
return globalObject.ERR_INVALID_ARG_TYPE(fetch_error_blank_url, .{}).throw();
|
||||
}
|
||||
|
||||
if (url.port.len > 0 and !url.hasValidPort()) {
|
||||
if (!url.hasValidPort()) {
|
||||
bun.default_allocator.free(url.href);
|
||||
return globalObject.throwInvalidArguments("Invalid port", .{});
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ pub const URL = struct {
|
||||
}
|
||||
|
||||
pub fn hasValidPort(this: *const URL) bool {
|
||||
return (this.getPort() orelse 0) > 0;
|
||||
return this.port.len == 0 or (this.getPort() orelse 0) > 0;
|
||||
}
|
||||
|
||||
pub fn isEmpty(this: *const URL) bool {
|
||||
|
||||
Reference in New Issue
Block a user