2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-24 14:04:14 +03:00

fix: fixed missed dispatchBeforeRedirect argument (#5778)

Co-authored-by: Dmitriy Mozgovoy <robotshara@gmail.com>
This commit is contained in:
Zao Soula
2024-01-24 22:57:06 +00:00
committed by GitHub
parent 123f354b92
commit a1938ff073
4 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -396,7 +396,7 @@ declare namespace axios {
maxBodyLength?: number;
maxRedirects?: number;
maxRate?: number | [MaxUploadRate, MaxDownloadRate];
beforeRedirect?: (options: Record<string, any>, responseDetails: {headers: Record<string, string>}) => void;
beforeRedirect?: (options: Record<string, any>, responseDetails: {headers: Record<string, string>, statusCode: HttpStatusCode}) => void;
socketPath?: string | null;
transport?: any;
httpAgent?: any;
Vendored
+1 -1
View File
@@ -337,7 +337,7 @@ export interface AxiosRequestConfig<D = any> {
maxBodyLength?: number;
maxRedirects?: number;
maxRate?: number | [MaxUploadRate, MaxDownloadRate];
beforeRedirect?: (options: Record<string, any>, responseDetails: { headers: Record<string, string> }) => void;
beforeRedirect?: (options: Record<string, any>, responseDetails: {headers: Record<string, string>, statusCode: HttpStatusCode}) => void;
socketPath?: string | null;
transport?: any;
httpAgent?: any;
+2 -2
View File
@@ -53,12 +53,12 @@ const supportedProtocols = platform.protocols.map(protocol => {
*
* @returns {Object<string, any>}
*/
function dispatchBeforeRedirect(options) {
function dispatchBeforeRedirect(options, responseDetails) {
if (options.beforeRedirects.proxy) {
options.beforeRedirects.proxy(options);
}
if (options.beforeRedirects.config) {
options.beforeRedirects.config(options);
options.beforeRedirects.config(options, responseDetails);
}
}
+2 -2
View File
@@ -381,8 +381,8 @@ describe('supports http with nodejs', function () {
}).listen(4444, function () {
axios.get('http://localhost:4444/', {
maxRedirects: 3,
beforeRedirect: function (options) {
if (options.path === '/foo') {
beforeRedirect: function (options, responseDetails) {
if (options.path === '/foo' && responseDetails.headers.location === '/foo') {
throw new Error(
'Provided path is not allowed'
);