Move emptiness check to hasValidPort

This commit is contained in:
Kai Tamkun
2025-01-31 18:55:29 -08:00
parent 2e9e448498
commit 2bc637ccff
2 changed files with 2 additions and 2 deletions

View File

@@ -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", .{});
}

View File

@@ -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 {