From c95b060ccce77bc11fdda0e12feea28acd60f83e Mon Sep 17 00:00:00 2001 From: Ram-blip Date: Fri, 10 Jul 2026 14:29:52 +0530 Subject: [PATCH] fix(fetch): handle null init in Response.json Signed-off-by: Ram-blip --- lib/web/fetch/response.js | 4 +--- test/fetch/response-json.js | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/web/fetch/response.js b/lib/web/fetch/response.js index ffb7ce14074..f555ea94b15 100644 --- a/lib/web/fetch/response.js +++ b/lib/web/fetch/response.js @@ -45,9 +45,7 @@ class Response { static json (data, init = undefined) { webidl.argumentLengthCheck(arguments, 1, 'Response.json') - if (init !== null) { - init = webidl.converters.ResponseInit(init) - } + init = webidl.converters.ResponseInit(init) // 1. Let bytes the result of running serialize a JavaScript value to JSON bytes on data. const bytes = textEncoder.encode( diff --git a/test/fetch/response-json.js b/test/fetch/response-json.js index 46878cc0d82..3cb80388d98 100644 --- a/test/fetch/response-json.js +++ b/test/fetch/response-json.js @@ -10,6 +10,7 @@ const FOO_BAR = 'foo/bar' const INIT_TESTS = [ [undefined, 200, '', APPLICATION_JSON, {}], + [null, 200, '', APPLICATION_JSON, {}], [{ status: 400 }, 400, '', APPLICATION_JSON, {}], [{ statusText: 'foo' }, 200, 'foo', APPLICATION_JSON, {}], [{ headers: {} }, 200, '', APPLICATION_JSON, {}],