From ce6178923aca5cabd2cbf031770e5672e4e2ca62 Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Tue, 18 Jul 2023 13:02:52 +0100 Subject: [PATCH] Resolves https://github.com/JakeChampion/fetch/issues/928 --- fetch.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fetch.js b/fetch.js index 001ffeff..0ac3072b 100644 --- a/fetch.js +++ b/fetch.js @@ -537,10 +537,15 @@ export function fetch(input, init) { } xhr.onload = function() { + var responseHeaders = xhr.getAllResponseHeaders(); + var setCookie = xhr.getResponseHeader('set-cookie'); + if (setCookie) { + responseHeaders = responseHeaders.replace(setCookie, setCookie.replace(/\r?\n/g, ', ')); + } var options = { status: xhr.status, statusText: xhr.statusText, - headers: parseHeaders(xhr.getAllResponseHeaders() || '') + headers: parseHeaders(responseHeaders || '') } options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL') var body = 'response' in xhr ? xhr.response : xhr.responseText