Commit Graph

200 Commits

Author SHA1 Message Date
Jason Saayman
24c45391b6
fix: backport the fixes from the v1 branch 2026-04-10 21:17:29 +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
qiongshusheng
4840cb2bd0
fix: regular expression denial of service issues (#6708)
* fix: Regular Expression Denial of Service (ReDoS)

* fix test failed
2024-11-15 09:29:49 +02:00
Peter Williamson
3936f44b1a
Fix: omit nulls in params (#6394)
* fix: omit nulls when building params

* chore: fix prettier formatting

* fix: omit nulls when building params pt 2

---------

Co-authored-by: Jay <jasonsaayman@gmail.com>
2024-05-24 18:41:46 +02:00
Sean Powell
146848f3e4
fix: backported commit #6167 and #6163 (#6402) 2024-05-24 18:38:36 +02:00
briwa
111811eadc
fix(backport): custom params serializer support (#6263) 2024-03-28 18:54:20 +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
934f390cc3
URL params serializer; (#4734)
* Refactored BuildURL helper to use URLSearchParams serializer;

* Updated typings;
Added TS test;
2022-05-25 08:16:38 +02:00
Dmitriy Mozgovoy
807918bda2
Added enhanced toFormData implementation with additional options support; (#4704)
Updated default notation for arrays and objects to bracket style;
Added `multer/express.js` tests;
Updated README.md;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-11 19:30:08 +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
Dmitriy Mozgovoy
76432c18be
Fixed FormData posting in browser environment by reverting #3785; (#4640)
* Fixed posting FormData in browser environment by reverting #3785;

* Added ability to keep `Content-Type` header in non-standard browser environments;

* Added browser test of FormData posting using external HTTP service (https://httpbin.org/post);

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-04-27 11:26:52 +02:00
Dmitriy Mozgovoy
4f7e3e3a7a
Removed import of url module in browser build due to significant size overhead; (#4594)
Removed pointless `Malformed URL` checking in  client build;
2022-04-26 09:08:49 +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
João Gabriel Quaresma
195c8e5ff5
Returned error treated when requesting uncommon URL (#3544)
* Fixing error returned when requesting illegal URL

* Adding unit tests http.js

* Fixing error message axios invalid request from browser

* Adding unit tests requests.spec.js

* Adding at utils.js a new method: getProtocol

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-03-07 19:53:57 +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
d660e29c1a
Revert "Fixed isFormData predicate; (#4413)" (#4472)
This reverts commit 73e3bdb883.
2022-02-13 15:47:38 +02:00
Dmitriy Mozgovoy
73e3bdb883
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 through `form-data` package;
2022-02-02 13:48:44 +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
Jay
5c5cbdf4ba Removed cancel token request test till debugging on FireFox can be done 2022-01-18 09:24:55 +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
Ben Carp
99648153ce
toFormData helper function (#3757)
* adding toFormData test

* adding toFormData

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-23 10:21:51 +02:00
Wolfram Kriesing
e6aef5a1c4
(Add tests to) document how multiple inceptors work (#3564)
* Add a group for the multiple-interceptors tests.

The current test contains a lot of details that are worth being tested
separately and also made explicit. This is what is coming with the next changes.

* Fix indentation.

* Make explicit that the test only tests the interception of the fulfilled part.

* Indent.

* Make the test just test a tiny bit, as described.

The more explicit the test, the better we can 1) describe what it does
and use that for the docs to make them understandable 2) have a better
explicit description of the API (in case we want to modify it) and 3) have
a regression test when changing.

* Add a test that explicitly shows that the order of interceptors is as they were added.

* Pull out reusable code, to make the tests more explicitly stating the things they care about.

* Write a test showing that the responses are not merged or anything,
only the last one in the chain is returned.

* Make visible that the interceptors are a chain, one receives its predecessor's data.

* Test what happens when the interceptor throws.

* Refactor, add another group of tests and pull helper function there.

The previous change to also catch in the helper function was not needed
for any of the tests above, so remove it and put it in the describe-block
below where it is needed.
Just trying to write the specific code needed, not more.
Not sure about the impact for failing tests, I am glad about input.
But the main intention here is to have minimal code, explicit tests and
not too much generic code which might break itself eventually.

* Documenting that the following reject-interceptor gets called.

* Documenting how the interceptor chain handles caught rejections.

* Document "multiple interceptors".

I just extracted the test descriptions from the new/modified tests.
And I also learned that I should improve the test descriptions, the
tests are just in a GIVEN-WHEN-THEN structure, so I can also use those
terms better. Will do this next.

* Transfer the better readable descriptions as I changed them in the README back into the tests.

After I had updated the README using the test descriptions I realized how
the test descriptions can be improved, so I did this "moving" the learnings
back into the code.

* Be a bit more explicit, it was not clear when reading, imho.

* Add new lines to be kinda consistent with the rest of the file.

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-22 21:14:52 +02:00
Black-Hole
6fca6a7027
refactor(helpers): optimize the logic of isAxiosError (#3546)
1. add the judgment of null

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-22 21:09:33 +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
Jay
4091b075f6
Release/0.21.4 (#4025)
* fix json transform when data is pre-stringified (#4020)

* [Updating] incorrect JSON syntax in README.md

* [Releasing] v0.21.4

Co-authored-by: Guillaume FORTAINE <guillaume+github@fortaine.com>
2021-09-06 17:35:06 +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
Daniel Lopretto
dbc634cf70
Remove charset in tests (#3807)
* removed charset setting when setting default header

* Remove charset from tests

Co-authored-by: mpark86 <dev.minuk.park@gmail.com>
Co-authored-by: Jay <jasonsaayman@gmail.com>
Co-authored-by: Pilot <timemachine@ctrl-c.club>
2021-05-21 07:51:31 +02:00
Dmitriy Mozgovoy
7821ed2089
Feat/json improvements (#3763)
* 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);

* Removed unnecessary assertion;
2021-04-19 22:05:48 +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
Jason Kwok
f472e5da5f
Adding a type guard for AxiosError (#2949)
Co-authored-by: Jason Kwok <JasonHK@users.noreply.github.com>
2020-11-03 10:01:07 +02:00
Kevin Kirsche
6d05b96dca
Fix typos (#3309)
Fix typos
2020-10-03 12:25:07 -06: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
Allan Cruz
04d45f2091
Fixing requestHeaders.Authorization (#3287) 2020-09-20 10:19:48 +08:00
Tim Gates
e8c6e19141
docs: Fix simple typo, existant -> existent (#3252) 2020-09-12 12:29:35 +08:00
rockcs1992
36f0ad2f98
Replace 'blacklist' with 'blocklist' (#3006) 2020-06-10 13:47:31 -06: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
f2b478f7ff
Revert "Fixing default transformRequest with buffer pools (#1511)" (#2982)
This reverts commit a9a3b5e22b.
2020-05-27 20:05:26 +02:00