1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-22 15:06:54 -05:00

fix(op_crates/fetch): ensure Request.method to be string (#8100)

Ensure "Request.method" to be the default value ("GET") if 
"init.method" is not defined, which follows browser's behavior.
This commit is contained in:
Kid 2020-10-26 22:02:08 +08:00 committed by GitHub
parent b65171e37d
commit 4c41ba5ad7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View file

@ -41,6 +41,10 @@ unitTest(function requestNonString(): void {
assertEquals(new Request(nonString).url, "http://foo/"); assertEquals(new Request(nonString).url, "http://foo/");
}); });
unitTest(function methodNonString(): void {
assertEquals(new Request("http://foo/", { method: undefined }).method, "GET");
});
unitTest(function requestRelativeUrl(): void { unitTest(function requestRelativeUrl(): void {
// TODO(nayeemrmn): Base from `--location` when implemented and set. // TODO(nayeemrmn): Base from `--location` when implemented and set.
assertThrows(() => new Request("relative-url"), TypeError, "Invalid URL."); assertThrows(() => new Request("relative-url"), TypeError, "Invalid URL.");

View file

@ -990,7 +990,7 @@
this.url = new URL(String(input)).href; this.url = new URL(String(input)).href;
} }
if (init && "method" in init) { if (init && "method" in init && init.method) {
this.method = normalizeMethod(init.method); this.method = normalizeMethod(init.method);
} }