aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/webcore/request.zig
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-07-11 19:14:34 -0700
committerGravatar GitHub <noreply@github.com> 2023-07-11 19:14:34 -0700
commitcbb88672f217a90db1aa1eb29cd92d5d9035b22b (patch)
tree43a00501f3cde495967e116f0b660777051551f8 /src/bun.js/webcore/request.zig
parent1f900cff453700b19bca2acadfe26da4468c1282 (diff)
parent34b0e7a2bbd8bf8097341cdb0075d0908283e834 (diff)
downloadbun-cbb88672f217a90db1aa1eb29cd92d5d9035b22b.tar.gz
bun-cbb88672f217a90db1aa1eb29cd92d5d9035b22b.tar.zst
bun-cbb88672f217a90db1aa1eb29cd92d5d9035b22b.zip
Merge branch 'main' into jarred/esm-conditionsjarred/esm-conditions
Diffstat (limited to 'src/bun.js/webcore/request.zig')
-rw-r--r--src/bun.js/webcore/request.zig20
1 files changed, 4 insertions, 16 deletions
diff --git a/src/bun.js/webcore/request.zig b/src/bun.js/webcore/request.zig
index a8c648212..cff2ef2f3 100644
--- a/src/bun.js/webcore/request.zig
+++ b/src/bun.js/webcore/request.zig
@@ -255,19 +255,7 @@ pub const Request = struct {
this: *Request,
globalThis: *JSC.JSGlobalObject,
) callconv(.C) JSC.JSValue {
- const string_contents: string = switch (this.method) {
- .GET => "GET",
- .HEAD => "HEAD",
- .PATCH => "PATCH",
- .PUT => "PUT",
- .POST => "POST",
- .OPTIONS => "OPTIONS",
- .CONNECT => "CONNECT",
- .TRACE => "TRACE",
- .DELETE => "DELETE",
- };
-
- return ZigString.init(string_contents).toValueGC(globalThis);
+ return bun.String.static(@tagName(this.method)).toJSConst(globalThis);
}
pub fn getMode(
@@ -472,8 +460,8 @@ pub const Request = struct {
url_or_object,
if (is_first_argument_a_url) JSValue.undefined else url_or_object,
};
- const values_to_try = values_to_try_[0 .. @as(usize, @boolToInt(!is_first_argument_a_url)) +
- @as(usize, @boolToInt(arguments.len > 1 and arguments[1].isObject()))];
+ const values_to_try = values_to_try_[0 .. @as(usize, @intFromBool(!is_first_argument_a_url)) +
+ @as(usize, @intFromBool(arguments.len > 1 and arguments[1].isObject()))];
for (values_to_try) |value| {
const value_type = value.jsType();
@@ -564,7 +552,7 @@ pub const Request = struct {
fields.insert(.url);
// first value
- } else if (@enumToInt(value) == @enumToInt(values_to_try[values_to_try.len - 1]) and !is_first_argument_a_url and
+ } else if (@intFromEnum(value) == @intFromEnum(values_to_try[values_to_try.len - 1]) and !is_first_argument_a_url and
value.implementsToString(globalThis))
{
const slice = value.toSliceOrNull(globalThis) orelse {