fix(core): Ensure maxRedirects is used for any http request defining it (#8706)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2024-02-22 17:56:48 +01:00
committed by GitHub
parent 8c4a744c56
commit 246c988b93
5 changed files with 62 additions and 17 deletions

View File

@@ -480,16 +480,14 @@ export async function parseRequestObject(requestObject: IRequestOptions) {
}
// Axios will follow redirects by default, so we simply tell it otherwise if needed.
const { method } = requestObject;
if (
requestObject.followRedirect === false &&
((requestObject.method as string | undefined) || 'get').toLowerCase() === 'get'
) {
axiosConfig.maxRedirects = 0;
}
if (
requestObject.followAllRedirects === false &&
((requestObject.method as string | undefined) || 'get').toLowerCase() !== 'get'
(requestObject.followRedirect !== false &&
(!method || method === 'GET' || method === 'HEAD')) ||
requestObject.followAllRedirects
) {
axiosConfig.maxRedirects = requestObject.maxRedirects;
} else {
axiosConfig.maxRedirects = 0;
}