fix(ext/fetch): Guard against invalid URL before its used by reqwest (#17164)

This commit is contained in:
Kamil Ogórek 2022-12-23 17:39:14 +01:00 committed by GitHub
parent e58cdbcb4b
commit 2a61b5fdd4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View file

@ -93,6 +93,19 @@ Deno.test(
},
);
Deno.test(
{ permissions: { net: true } },
async function fetchMalformedUriError() {
await assertRejects(
async () => {
const url = new URL("http://{{google/");
await fetch(url);
},
TypeError,
);
},
);
Deno.test({ permissions: { net: true } }, async function fetchJsonSuccess() {
const response = await fetch("http://localhost:4545/assets/fixture.json");
const json = await response.json();