From 25e9ebcd51b2b82680e1a6eb35d2b0609f10a7ab Mon Sep 17 00:00:00 2001 From: Phil Pluckthun Date: Sun, 1 Feb 2026 22:31:35 +0000 Subject: [PATCH] fix: Protect against missing `Symbol.toStringTag` (#19) --- .changeset/wild-beers-repeat.md | 5 +++++ src/body.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/wild-beers-repeat.md 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; } -- 2.51.2