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:
parent
b65171e37d
commit
4c41ba5ad7
2 changed files with 5 additions and 1 deletions
|
@ -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.");
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue