Commit Graph

94 Commits

Author SHA1 Message Date
Jason Saayman
24c45391b6
fix: backport the fixes from the v1 branch 2026-04-10 21:17:29 +02:00
Felix Bernhard
d7ff1409c6
fix: backport DOS via __proto__ key in merge config fix to v0.x (#7388)
* backport fix

* add unit tests

* use `require()` instead of `import`
2026-02-11 08:19:32 +02:00
Gabe Mendoza
02c3c69ced
fix: backport allowAbsoluteUrls vuln fix to v0.x (#6829)
* allowAbsoluteUrls

* fix logic - copied from v1.x

* update string

* undo changes to dist/axios.js

* chore: use strict equal in lib/core/buildFullPath.js

---------

Co-authored-by: Jay <jasonsaayman@gmail.com>
2025-03-19 12:24:25 +02:00
Sol Zhu
2e36cdb67f
fix(backport): fix paramsSerializer function validation (#6361)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2024-05-24 18:44:36 +02:00
briwa
111811eadc
fix(backport): custom params serializer support (#6263) 2024-03-28 18:54:20 +02:00
Dmitriy Mozgovoy
27c007656d
feat(backport): added ability for paramsSerializer to handle function; (#6227) 2024-02-12 20:05:36 +02:00
lnjbr
2755df562b
fix(security): fixed CVE-2023-45857 by backporting withXSRFToken option to v0.x (#6091) 2024-01-19 18:33:41 +02:00
Willian Agostini
80b546c3f1
fix: loosing request header (#4858) (#4871)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-09-26 21:05:57 +02:00
João Gabriel Quaresma
1504792765
Fixing content-type header repeated (#4745)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-28 11:52:50 +02:00
Dmitriy Mozgovoy
c008e57fe4
Added axios.formToJSON method; (#4735)
* Draft

* Added `formDataToJSON` helper;
Added `axios.formToJSON` method;
Added client tests;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-25 08:21:40 +02:00
Dmitriy Mozgovoy
c30252f685
Added data URL support for node.js; (#4725)
* Added data URL support for node.js;
Added missed data URL protocol for the browser environment;
Optimized JSON parsing in the default response transformer;
Refactored project structure;
Added `cause` prop for AxiosError instance that refers to the original error if it was wrapped with `AxiosError.from` method;
Added fromDataURI helper;
Added test for handling data:url as an `arraybuffer|text|stream`;

* Added throwing of 405 HTTP error if the method is not GET;
2022-05-20 08:04:36 +02:00
Dmitriy Mozgovoy
d60d6844b1
Fixed AxiosError stack capturing; (#4718)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-16 08:58:47 +02:00
Koki Oyatsu
2f50c8249b
Adding HTTP status code for transformResponse (#4580)
* Adding HTTP status code for transformResponse

* refs #1214

* Fix wrong argument for tranformResponse

* Fix test wrong argument for tranformData

* Add test case for transformData

* Add test case for transformData (reference headers case)

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-09 19:25:16 +02:00
Landro3
544cf134f3
Interceptor clear (#4248)
* Adding interceptor clearing

* Fixing spacing

* changed clear to empty array

* fixed interceptor clear test

Co-authored-by: Andrew <Andrew@Andrews-MacBook-Pro.local>
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-05 21:31:06 +02:00
Des Preston
7920d11144
Updating AxiosError to include stack trace (#4624)
Related to discussions here https://github.com/axios/axios/issues/2387

Attempt to capture the stack trace at the time the error is created in
order to maintain context about where the error originates from.

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-03 18:46:10 +02:00
Jay
8699891b8e Fixed merge conflicts 2022-04-01 18:40:12 +02:00
Dmitriy Mozgovoy
6b9b05b907
Improved FormData support; (#4448)
* Fixed isFormData predicate;
Added support for automatic object serialization to FormData if `Content-Type` is `multipart/form-data`;
Added support for FormData to be overloaded using `config.env.FormData` option;
Added support for FormData in node.js environment through `form-data` package;

* Added the `form-data` package as a dependency for the server build;
Added tests for FormData payload;

* Added FormData automatic serialization section;
Refactored cancellation section;

* Reworked toFormData helper;
Expose toFormData helper as a static method;
Refactored transform request;
Added kindOf, kindOfTest, endsWith, isTypedArray util;
Refactored utils.js to use kindOf for tests;

* Fixed isFormData predicate; (#4413)

Added support for automatic object serialization to FormData if `Content-Type` is `multipart/form-data`;
Added support for FormData to be overloaded using `config.env.FormData` option;
Added support for FormData in node.js environment using `form-data` package;

(cherry picked from commit 73e3bdb883)

* Added shortcut methods `postForm`, `putForm`, `patchForm` to submit a Form;
Added ability to submit FileList object as a FormData;
Updated README.md;

* Updated README.md;
2022-03-14 20:22:10 +02:00
Jay
340ad9ec8c Fixed merge conflict 2022-03-09 19:57:04 +02:00
Jay
d8d43c1ffd Mended merge conflicts 2022-03-09 19:41:56 +02:00
sakarit
bdb7d76d40
Adding baseURL to be used in getUri(), also removing question mark trimming since there seems to be no obvious reason for it. (#3737)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-03-07 20:09:23 +02:00
Zoran Kokeza
412d3bd607
Adding support for beforeRedirect config option (#3852)
* Adding support for beforeRedirect config option

* Adding tests for beforeRedirect

* Update README.md

Co-authored-by: Prabodh Meshram <prabodh.meshram7@gmail.com>

* fix types

Co-authored-by: Prabodh Meshram <prabodh.meshram7@gmail.com>
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-03-07 19:46:08 +02:00
Dmitriy Mozgovoy
170588f3d7
Refactored project file structure to avoid circular imports; (#4220)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-03-07 09:09:43 +02:00
Jay
cc86c6c49f
Fix/remove url required (#4426)
* Removed error when url is null as this breaks current use cases for alot of projects

* Removed associated tests that check for the for url to not be empty
2022-01-27 08:39:25 +02:00
Hirotaka Tagawa / wafuwafu13
95792908f0
Adding error handling when missing url (#3791)
* Fixing error message when missing url

* Fixing missing url

* Adding missing url case

* Update Axios.js

* Update requests.spec.js

* Update api.spec.js

* Update api.spec.js

* Update api.spec.js

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-23 10:53:40 +02:00
Emil Broman
cd1b82bb76
Removing code relying on strict mode behaviour for arguments (#3470)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-22 20:58:12 +02:00
DigitalBrainJS
7f1236652a Refactored AxiosError to a constructor;
Refactored `Cancel` to a constructor, a subclass of the `AxiosError`;
Expose CanceledError class;
Refactored axios error codes;
Added `toFlatObject` util;
2021-10-14 19:15:16 +03:00
Jay
76f09afc03
Release/v0.22.0 (#4107)
* fix/Avoid package.json import; (#4041)

* Added auto-generated config module `env/data.js` for importing package environment vars without importing the whole `package.json`;
Refactored `http.js` to use `env/data.js` instead of package.json;

* Added `env/data.js`;
Added `env/README.md`;

* Feat/export package version constant (#4065)

* Added auto-generated config module `env/data.js` for importing package environment vars without importing the whole `package.json`;
Refactored `http.js` to use `env/data.js` instead of package.json;

* Added `env/data.js`;
Added `env/README.md`;

* Export package version constant;

* Fixed cancelToken leakage; Added AbortController support; (#3305)

* Fixed cancelToken leakage;
Added AbortController support;

* Fixed typings;

* Documented `signal` option;

* Added processing of early cancellation using AbortController without sending a request;

Co-authored-by: Jay <jasonsaayman@gmail.com>

* Updating CI to run on release branches

* Fixed default transitional config for custom Axios instance; (#4052)

Refactored `/core/mergeConfig`;

Co-authored-by: Jay <jasonsaayman@gmail.com>

* Prepping v0.22.0 for release

* Updated date

Co-authored-by: Dmitriy Mozgovoy <robotshara@gmail.com>
2021-10-01 08:02:13 +02:00
Greg Byrne
cd7ff042b0
Adding HTTP status code to error.toJSON (#2956)
* Adding HTTP status code to error.toJSON (axios#2947)

* Adding Error display div to internal server client.html

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-09-05 13:45:24 +02:00
Julian Hollmann
83ae3830e4
Correctly add response interceptors to interceptor chain (#4013) 2021-09-04 20:55:38 +02:00
TagawaHirotaka
a18a0eccb5
Updating lib/core/README.md about Dispatching requests (#3772)
* Updating lib/core/README.md :Dispatching requests

* Fixing expression
2021-04-30 09:08:50 +02:00
Dmitriy Mozgovoy
5ad6994da3
JSON improvements: throw if JSON parsing failed; number, boolean can be passed directly as payload for encoding to JSON #2613, #61, #907 (#3688)
* Draft

* Added support for primitive types to be converted to JSON if the request Content-Type is 'application/json';
Added throwing SyntaxError if JSON parsing failed and responseType is json;
Added transitional option object;
Added options validator to assert transitional options;
Added transitional option `silentJSONParsing= true` for backward compatibility;
Updated README.md;
Updated typings;

* Fixed isOlderVersion helper;
Fixed typo;
Added validator.spec.js;

* Added forcedJSONParsing transitional option #2791

* `transformData` is now called in the default configuration context if the function context is not specified (for tests compatibility);

* Added `transitional.clarifyTimeoutError` to throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts;
Added support of onloadend handler if available instead of onreadystatechange;
Added xhr timeout test;
Fixed potential bug of xhr adapter with proper handling timeouts&errors (FakeXMLHTTPRequest failed to handle timeouts);
2021-04-19 18:55:34 +02:00
Sasha Korotkov
62d6256039
issue#2609 | Sasha | predictable axios requests (#2702)
* issue#2609 | Sasha | predictable axios requests

- axios requests are not delayed by pre-emptive promise creation by default
- add options to interceptors api ("synchronous" and "runWhen")
- add documentation and unit tests

* issue#2609 | Sasha | pull request feedback changes

* issue#2609 | Sasha | additional feedback changes

* issue#2609 | Sasha | put back try/catch

* issue#2609 | Sasha | add 2 adapter unit tests

- remove check for requestCancelled

Co-authored-by: ak71845 <alexandre.korotkov@kroger.com>
Co-authored-by: Xianming Zhong <chinesedfan@qq.com>
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-03-01 11:11:35 +02:00
Xianming Zhong
fa3673710e
fix axios.delete ignores config.data (#3282)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2020-10-01 09:46:32 +02:00
Xianming Zhong
0d69a79c81
Refactor mergeConfig without utils.deepMerge (#2844)
* Adding failing test

* Fixing #2587 default custom config persisting

* Adding Concat keys and filter duplicates

* Fixed value from CPE

* update for review feedbacks

* no deepMerge

* only merge between plain objects

* fix rename

* always merge config by mergeConfig

* extract function mergeDeepProperties

* refactor mergeConfig with all keys, and add special logic for validateStatus

* add test for resetting headers

* add lots of tests and fix a bug

* should not inherit `data`

* use simple toString

* revert #1845

Co-authored-by: David Tanner <david.tanner@lifeomic.com>
Co-authored-by: Justin Beckwith <justin.beckwith@gmail.com>
2020-06-08 20:52:45 +02:00
Martti Laine
487941663b
Allow unsetting headers by passing null (#382) (#1845)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2020-06-04 20:57:54 +02:00
Jay
cbda78552b
Revert "Bug/allow header to contain http verb keys #1252 (#1258)" (#2977)
This reverts commit 920510b3a6.
2020-05-22 21:44:26 +02:00
David Ko
920510b3a6
Bug/allow header to contain http verb keys #1252 (#1258)
* Failing test for #1252

* Only delete header keys that match an HTTP verb if the value is a non-string

Co-authored-by: David Ko <david.ko@pvtmethod.com>
Co-authored-by: Jay <jasonsaayman@gmail.com>
2020-05-22 21:26:10 +02:00
Alan Wang
885ada6d9b
Fixing getting local files (file://) failed (#2470)
* fix issue #2416, #2396

* fix Eslint warn

* Modify judgment conditions

* add unit test

* update unit test

* update unit test
2020-03-23 21:49:38 +08:00
Gustavo López
6642ca9aa1
Add independent maxBodyLength option (#2781)
* Add independent option to set the maximum size of the request body

* Remove maxBodyLength check

* Update README

* Assert for error code and message
2020-03-06 21:55:19 +08:00
Thibault Ehrhart
17a967123c
Adding responseEncoding to mergeConfig (#1745)
Co-authored-by: Xianming Zhong <chinesedfan@qq.com>
2020-02-15 21:49:26 +08:00
Jonathan Sharpe
77f0ae4f61
Fix merging of params (#2656)
* Name function to avoid ESLint func-names warning

* Switch params config to merge list and update tests

* Restore testing of both false and null

* Restore test cases for keys without defaults

* Include test for non-object values that aren't false-y.
2020-02-15 13:36:52 +08:00
不才
ee47120a09 If this place is false, it will report an error, so you should delete the useless code. (#2458) 2019-12-25 13:00:15 -08:00
Felipe Martins
097948698a
Revert "Update Webpack + deps, remove now unnecessary polyfills" (#2479)
* Revert "Update Webpack + deps, remove now unnecessary polyfills (#2410)"

This reverts commit 189b34c45a.

* Fix build (#2496)

* Change syntax to see if build passes

* Test commit

* Test with node 10

* Test adding all browsers in travis

* remove other browsers when running on travis
2019-10-25 11:34:47 -03:00
Avindra Goolcharan
189b34c45a Update Webpack + deps, remove now unnecessary polyfills (#2410)
* Update deps

 * handles webpack 1 -> 4 migration

* remove promise helpers from dev files

assume `Promise` is available, or polyfilled by
the consumer

* Remove isArray util. `isArray` has good coverage, even
   in IE9. So lets remove the custom polyfill.

 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray

also resolves a few lint issues

* Remove trim util

String.protoype.trim has good coverage (including IE9)

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim

Also, the http adapter already uses the native method.
2019-10-21 15:56:29 -03:00
Rafael Renan Pacheco
a11cdf4683 Fixing custom config options (#2207)
- fixes #2203
2019-09-06 21:40:04 -03:00
bushuai
e50a08b2c3 Fixing set config.method after mergeConfig for Axios.prototype.request (#2383)
Inside Axios.prototype.request function, It's forced to set
method to 'get' after `mergeConfig` if config.method exists, which makes the defaults.method not effective.
2019-09-06 14:23:55 -03:00
DIO
89bd3abe9a Axios create url bug (#2290)
* Fix #2234 

* added spacing --eslint

* added test cases

* removed unexpected cases after updating the code
2019-09-06 12:45:18 -03:00
multicolaure
6fe506fda2 Do not modify config.url when using a relative baseURL (resolves #1628) (#2391)
* Adding tests to show config.url mutation

Because config.url is modified while processing the request
when the baseURL is set,
it is impossible to perform a retry with the provided config object.

Ref #1628

* Fixing url combining without modifying config.url

As config.url is not modified anymore during the request processing.
The request can safely be retried after it failed with the provided
config.

resolves #1628
2019-09-05 12:43:55 -03:00
Ayush Gupta
b681e919c4 Adding isAxiosError flag to errors thrown by axios (#1419) 2018-08-20 11:02:23 +02:00
Anthony Gauthier
4f98acc578 Add getUri method (#1712)
* Added getUri method

* Removed usage of "url"

* added method to README
2018-08-07 11:52:30 -06:00