diff options
Diffstat (limited to 'cli')
-rw-r--r-- | cli/js/web/body.ts | 7 | ||||
-rw-r--r-- | cli/tests/unit/body_test.ts | 7 |
2 files changed, 13 insertions, 1 deletions
diff --git a/cli/js/web/body.ts b/cli/js/web/body.ts index 6e376de37..8f5b48ad8 100644 --- a/cli/js/web/body.ts +++ b/cli/js/web/body.ts @@ -25,6 +25,8 @@ function validateBodyType(owner: Body, bodySource: BodyInit | null): boolean { return true; } else if (bodySource instanceof FormData) { return true; + } else if (bodySource instanceof URLSearchParams) { + return true; } else if (!bodySource) { return true; // null body is fine } @@ -193,7 +195,10 @@ export class Body implements domTypes.Body { ); } else if (this._bodySource instanceof ReadableStreamImpl) { return bufferFromStream(this._bodySource.getReader()); - } else if (this._bodySource instanceof FormData) { + } else if ( + this._bodySource instanceof FormData || + this._bodySource instanceof URLSearchParams + ) { const enc = new TextEncoder(); return Promise.resolve( enc.encode(this._bodySource.toString()).buffer as ArrayBuffer diff --git a/cli/tests/unit/body_test.ts b/cli/tests/unit/body_test.ts index a6df3102e..df824e1ae 100644 --- a/cli/tests/unit/body_test.ts +++ b/cli/tests/unit/body_test.ts @@ -72,3 +72,10 @@ unitTest( assertEquals(formData.get("field_2")!.toString(), "<Deno>"); } ); + +unitTest({ perms: {} }, async function bodyURLSearchParams(): Promise<void> { + const body = buildBody(new URLSearchParams({ hello: "world" })); + + const text = await body.text(); + assertEquals(text, "hello=world"); +}); |