From 9c852d09b09c77cad4c57003b6138120c99dc9a4 Mon Sep 17 00:00:00 2001 From: "Daniel A. White" Date: Thu, 4 May 2023 13:46:48 -0400 Subject: [PATCH] fix(http): allow for undefined headers --- lib/resolvers/http.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/resolvers/http.js b/lib/resolvers/http.js index 0137fe17..aae414c3 100644 --- a/lib/resolvers/http.js +++ b/lib/resolvers/http.js @@ -101,7 +101,7 @@ async function download (u, httpOptions, redirects) { // Certain implementations of `fetch` do not support URL based basic-auth // Convert to headers - const headers = new Headers(httpOptions.headers); + const headers = new Headers(httpOptions.headers || {}); if (u.auth && !headers.has("Authorization")) { headers.set("Authorization", "Basic " + btoa(u.auth)); } @@ -113,7 +113,7 @@ async function download (u, httpOptions, redirects) { /** @type {RequestInit} */ const init = { method: "GET", - headers: Object.fromEntries(headers.entries()), + headers, credentials: httpOptions.withCredentials ? "include" : "omit", signal: controller.signal, // browser fetch API does not support redirects https://fetch.spec.whatwg.org/#atomic-http-redirect-handling diff --git a/package.json b/package.json index e83fc42d..b0b67fe7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@stoplight/json-schema-ref-parser", - "version": "9.2.3", + "version": "9.2.4", "description": "Parse, Resolve, and Dereference JSON Schema $ref pointers", "keywords": [ "json",