diff --git a/cli/tests/unit/request_test.ts b/cli/tests/unit/request_test.ts index f1d5ef0551117..6fc8c0eb57283 100644 --- a/cli/tests/unit/request_test.ts +++ b/cli/tests/unit/request_test.ts @@ -41,6 +41,10 @@ unitTest(function requestNonString(): void { assertEquals(new Request(nonString).url, "http://foo/"); }); +unitTest(function methodNonString(): void { + assertEquals(new Request("http://foo/", { method: undefined }).method, "GET"); +}); + unitTest(function requestRelativeUrl(): void { // TODO(nayeemrmn): Base from `--location` when implemented and set. assertThrows(() => new Request("relative-url"), TypeError, "Invalid URL."); diff --git a/op_crates/fetch/26_fetch.js b/op_crates/fetch/26_fetch.js index 887e329f9d5bf..c8b2c8794c01c 100644 --- a/op_crates/fetch/26_fetch.js +++ b/op_crates/fetch/26_fetch.js @@ -990,7 +990,7 @@ this.url = new URL(String(input)).href; } - if (init && "method" in init) { + if (init && "method" in init && init.method) { this.method = normalizeMethod(init.method); }