Skip to content

Commit

Permalink
fix(op_crates/fetch): ensure Request.method to be string (denoland#8100)
Browse files Browse the repository at this point in the history
Ensure "Request.method" to be the default value ("GET") if 
"init.method" is not defined, which follows browser's behavior.
  • Loading branch information
kidonng committed Oct 26, 2020
1 parent b65171e commit 4c41ba5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cli/tests/unit/request_test.ts
Expand Up @@ -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.");
Expand Down
2 changes: 1 addition & 1 deletion op_crates/fetch/26_fetch.js
Expand Up @@ -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);
}

Expand Down

0 comments on commit 4c41ba5

Please sign in to comment.