diff --git a/.changeset/wild-beers-repeat.md b/.changeset/wild-beers-repeat.md new file mode 100644 index 0000000..906b006 --- /dev/null +++ b/.changeset/wild-beers-repeat.md @@ -0,0 +1,5 @@ +--- +'fetch-nodeshim': patch +--- + +Protect against missing `Symbol.toStringTag` diff --git a/src/body.ts b/src/body.ts index 65f8086..e1001b3 100644 --- a/src/body.ts +++ b/src/body.ts @@ -77,8 +77,8 @@ const isBlob = (object: any): object is Blob => { typeof object.stream === 'function' && typeof object.constructor === 'function' ) { - const tag = object[Symbol.toStringTag]; - return tag.startsWith('Blob') || tag.startsWith('File'); + const tag = object[Symbol.toStringTag] as string | undefined; + return !!tag && (tag.startsWith('Blob') || tag.startsWith('File')); } else { return false; }