2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00
Files
axios/lib/core
Liuwei1125 847d89b436 fix: support URL object as config.url input (#10866)
* fix(buildURL): support URL object as input

Fixes #6546

When passing a URL object (e.g., new URL(...)) to axios methods
like axios.get(url, { params: {...} }), the buildURL function
would crash with 'url.indexOf is not a function' because it assumed
url was always a string.

This fix converts URL objects to strings before processing.

* fix: support URL object as config.url input

- Move URL object coercion from buildURL to Axios._request so that all
  downstream consumers (buildFullPath, combineURLs, adapters) see a string.
  This fixes the crash when using URL object with baseURL (combineURLs
  calls .replace() on the URL object).
- Remove the broken buildURL unit test that tested buildURL(url, null)
  without actually exercising URL coercion (buildURL early-returns when
  !params).
- Add e2e tests via the HTTP adapter for URL object with params and
  URL object without params (no crash).

* feat: note + example added under axios(url[, config]) documenting URL support

* feat: url widened to string | URL

* feat: oercion now uses config.url instanceof url

* chore: add additional test cases to improve coverage

* fix: apply suggestions from cubic review

---------

Co-authored-by: liuwei53 <liuwei53@baidu.com>
Co-authored-by: Jason Saayman <jasonsaayman@gmail.com>
2026-05-09 19:09:13 +02:00
..

axios // core

The modules found in core/ should be modules that are specific to the domain logic of axios. These modules would most likely not make sense to be consumed outside of the axios module, as their logic is too specific. Some examples of core modules are:

  • Dispatching requests
    • Requests sent via adapters/ (see lib/adapters/README.md)
  • Managing interceptors
  • Handling config