Skip to content

Commit

Permalink
fix: check manifest candidate type against Response (#34)
Browse files Browse the repository at this point in the history
Fix a regression on node v18.18.2 and v21.0.0 introduced by 630fcd6.

In particular, in v18.18.2 and v21.0.0, the Response constructor's
name property is `_Response`, not `Response`. I originally added the
stringly-typed check to allow for alternative `fetch()` implementations,
so I've retained the string check but now additionally check to see whether
the candidate is `instanceof Response`.

Fixes #33
  • Loading branch information
chrisdickinson authored Dec 1, 2023
1 parent ad7e031 commit f62320e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async function _populateWasmField(candidate: ManifestLike, _fetch: typeof fetch)
candidate = new URL(candidate);
}

if (candidate?.constructor?.name === 'Response') {
if (candidate instanceof Response || candidate?.constructor?.name === 'Response') {
const response: Response = candidate as Response;
const contentType = response.headers.get('content-type') || 'application/octet-stream';

Expand Down

0 comments on commit f62320e

Please sign in to comment.