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

fix(ext/fetch): blob url (#16057)

Co-authored-by: Luca Casonato <hello@lcas.dev>
This commit is contained in:
Satya Rohith 2022-09-27 22:07:46 +05:30 committed by GitHub
parent a3b4037c8a
commit 7a47321b09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View file

@ -1773,3 +1773,20 @@ Deno.test(
listener.close();
},
);
Deno.test(
{ permissions: { net: true } },
async function fetchBlobUrl(): Promise<
void
> {
const blob = new Blob(["ok"], { type: "text/plain" });
const url = URL.createObjectURL(blob);
const res = await fetch(url);
console.log(res);
assert(res.url.startsWith("blob:http://js-unit-tests/"));
assertEquals(res.status, 200);
assertEquals(res.headers.get("content-length"), "2");
assertEquals(res.headers.get("content-type"), "text/plain");
assertEquals(await res.text(), "ok");
},
);

View file

@ -165,6 +165,7 @@
const body = new InnerBody(req.blobUrlEntry.stream());
terminator[abortSignal.add](() => body.error(terminator.reason));
processUrlList(req.urlList, req.urlListProcessed);
return {
headerList: [
@ -179,7 +180,9 @@
if (this.urlList.length == 0) return null;
return this.urlList[this.urlList.length - 1];
},
urlList: recursive ? [] : [...new SafeArrayIterator(req.urlList)],
urlList: recursive
? []
: [...new SafeArrayIterator(req.urlListProcessed)],
};
}