diff options
-rw-r--r-- | cli/tests/unit/request_test.ts | 4 | ||||
-rw-r--r-- | op_crates/fetch/26_fetch.js | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/cli/tests/unit/request_test.ts b/cli/tests/unit/request_test.ts index f1d5ef055..6fc8c0eb5 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 887e329f9..c8b2c8794 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); } |