@whatwg-node/node-fetch
Advanced tools
Comparing version 0.7.9-rc-20250213120211-2e564250f0d6354be9db6c60c01427b07608eed5 to 0.7.9-rc-20250213120319-65bba01336a8eadc30749e414db6760a759f4b38
@@ -121,3 +121,4 @@ "use strict"; | ||
if (fetchRequest.redirect === 'error' && | ||
(headerFilter.includes('location') || headerFilter.includes('Location'))) { | ||
headerFilter.toLowerCase().includes('location') && | ||
(0, utils_js_1.shouldRedirect)(status)) { | ||
if (!stream.destroyed) { | ||
@@ -124,0 +125,0 @@ stream.resume(); |
@@ -76,3 +76,3 @@ "use strict"; | ||
} | ||
if (nodeResponse.headers.location) { | ||
if (nodeResponse.headers.location && (0, utils_js_1.shouldRedirect)(nodeResponse.statusCode)) { | ||
if (fetchRequest.redirect === 'error') { | ||
@@ -79,0 +79,0 @@ const redirectError = new Error('Redirects are not allowed'); |
@@ -10,2 +10,3 @@ "use strict"; | ||
exports.isIterable = isIterable; | ||
exports.shouldRedirect = shouldRedirect; | ||
function isHeadersInstance(obj) { | ||
@@ -92,1 +93,4 @@ return obj?.forEach != null; | ||
} | ||
function shouldRedirect(status) { | ||
return status === 301 || status === 302 || status === 303 || status === 307 || status === 308; | ||
} |
@@ -5,3 +5,3 @@ import { PassThrough, Readable } from 'node:stream'; | ||
import { PonyfillResponse } from './Response.js'; | ||
import { createDeferredPromise, defaultHeadersSerializer, isNodeReadable } from './utils.js'; | ||
import { createDeferredPromise, defaultHeadersSerializer, isNodeReadable, shouldRedirect, } from './utils.js'; | ||
export function fetchCurl(fetchRequest) { | ||
@@ -119,3 +119,4 @@ const { Curl, CurlFeature, CurlPause, CurlProgressFunc } = globalThis['libcurl']; | ||
if (fetchRequest.redirect === 'error' && | ||
(headerFilter.includes('location') || headerFilter.includes('Location'))) { | ||
headerFilter.toLowerCase().includes('location') && | ||
shouldRedirect(status)) { | ||
if (!stream.destroyed) { | ||
@@ -122,0 +123,0 @@ stream.resume(); |
@@ -9,3 +9,3 @@ import { request as httpRequest, STATUS_CODES } from 'node:http'; | ||
import { PonyfillURL } from './URL.js'; | ||
import { getHeadersObj, isNodeReadable } from './utils.js'; | ||
import { getHeadersObj, isNodeReadable, shouldRedirect } from './utils.js'; | ||
function getRequestFnForProtocol(url) { | ||
@@ -74,3 +74,3 @@ if (url.startsWith('http:')) { | ||
} | ||
if (nodeResponse.headers.location) { | ||
if (nodeResponse.headers.location && shouldRedirect(nodeResponse.statusCode)) { | ||
if (fetchRequest.redirect === 'error') { | ||
@@ -77,0 +77,0 @@ const redirectError = new Error('Redirects are not allowed'); |
@@ -82,1 +82,4 @@ function isHeadersInstance(obj) { | ||
} | ||
export function shouldRedirect(status) { | ||
return status === 301 || status === 302 || status === 303 || status === 307 || status === 308; | ||
} |
{ | ||
"name": "@whatwg-node/node-fetch", | ||
"version": "0.7.9-rc-20250213120211-2e564250f0d6354be9db6c60c01427b07608eed5", | ||
"version": "0.7.9-rc-20250213120319-65bba01336a8eadc30749e414db6760a759f4b38", | ||
"description": "Fetch API implementation for Node", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
@@ -14,1 +14,2 @@ import { Readable } from 'node:stream'; | ||
export declare function isIterable(value: any): value is Iterable<unknown>; | ||
export declare function shouldRedirect(status?: number): boolean; |
Sorry, the diff of this file is not supported yet
221608
5611