Skip to content

Commit

Permalink
Patch axios
Browse files Browse the repository at this point in the history
Related to axios/axios#5090
  • Loading branch information
kachkaev committed Oct 23, 2022
1 parent 599ebe0 commit 6c3288a
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 2 deletions.
74 changes: 74 additions & 0 deletions .yarn/patches/axios-npm-1.1.3-4b63965ac1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
diff --git a/dist/axios.js b/dist/axios.js
index 5c85690b0eb51c137e8febb65fe37a51e1ae11bc..96dfd12f78c1228c97187ff578c1ceb49e2f1a54 100644
--- a/dist/axios.js
+++ b/dist/axios.js
@@ -1516,7 +1516,7 @@
}
self[key || _header] = normalizeValue(_value);
}
- if (utils.isPlainObject(header)) {
+ if (utils.isPlainObject(header) || header instanceof AxiosHeaders) {
utils.forEach(header, function (_value, _header) {
setHeader(_value, _header, valueOrRewrite);
});
@@ -2342,7 +2342,7 @@
config.method = (config.method || this.defaults.method || 'get').toLowerCase();

// Flatten headers
- var defaultHeaders = config.headers && utils.merge(config.headers.common, config.headers[config.method]);
+ var defaultHeaders = config.headers && utils.merge(this.defaults.headers.common, this.defaults.headers[config.method]);
defaultHeaders && utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], function cleanHeaderConfig(method) {
delete config.headers[method];
});
diff --git a/dist/esm/axios.js b/dist/esm/axios.js
index b08fb87e5845d036d93545d9754f81762c6ca6a3..1b94a2a947957800d728effa56a966563dcfaad5 100644
--- a/dist/esm/axios.js
+++ b/dist/esm/axios.js
@@ -1622,7 +1622,7 @@ Object.assign(AxiosHeaders.prototype, {
self[key || _header] = normalizeValue(_value);
}

- if (utils.isPlainObject(header)) {
+ if (utils.isPlainObject(header) || header instanceof AxiosHeaders) {
utils.forEach(header, (_value, _header) => {
setHeader(_value, _header, valueOrRewrite);
});
@@ -2611,8 +2611,8 @@ class Axios {

// Flatten headers
const defaultHeaders = config.headers && utils.merge(
- config.headers.common,
- config.headers[config.method]
+ this.defaults.headers.common,
+ this.defaults.headers[config.method]
);

defaultHeaders && utils.forEach(
diff --git a/lib/core/Axios.js b/lib/core/Axios.js
index 31f8b531dc5b1aa70873de19f21efe6d4ed75deb..11b8b922a12df0ecf472ef0e3822639b9c0aed27 100644
--- a/lib/core/Axios.js
+++ b/lib/core/Axios.js
@@ -69,8 +69,8 @@ class Axios {

// Flatten headers
const defaultHeaders = config.headers && utils.merge(
- config.headers.common,
- config.headers[config.method]
+ this.defaults.headers.common,
+ this.defaults.headers[config.method]
);

defaultHeaders && utils.forEach(
diff --git a/lib/core/AxiosHeaders.js b/lib/core/AxiosHeaders.js
index 68e098a0f7e910779fffd5d5ff2c684d8dd7e5e6..87f745f2071c330c050cc51fab5e950d426e05b4 100644
--- a/lib/core/AxiosHeaders.js
+++ b/lib/core/AxiosHeaders.js
@@ -105,7 +105,7 @@ Object.assign(AxiosHeaders.prototype, {
self[key || _header] = normalizeValue(_value);
}

- if (utils.isPlainObject(header)) {
+ if (utils.isPlainObject(header) || header instanceof AxiosHeaders) {
utils.forEach(header, (_value, _header) => {
setHeader(_value, _header, valueOrRewrite);
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"dependencies": {
"@next/eslint-plugin-next": "12.3.1",
"axios": "1.1.3",
"axios": "patch:axios@npm%3A1.1.3#~/.yarn/patches/axios-npm-1.1.3-4b63965ac1.patch",
"axios-retry": "3.3.1",
"csv-parse": "5.3.1",
"dotenv-flow": "3.2.0",
Expand Down
13 changes: 12 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1732,6 +1732,17 @@ __metadata:
languageName: node
linkType: hard

"axios@patch:axios@npm%3A1.1.3#~/.yarn/patches/axios-npm-1.1.3-4b63965ac1.patch":
version: 1.1.3
resolution: "axios@patch:axios@npm%3A1.1.3#~/.yarn/patches/axios-npm-1.1.3-4b63965ac1.patch::version=1.1.3&hash=2e2dd0"
dependencies:
follow-redirects: "npm:^1.15.0"
form-data: "npm:^4.0.0"
proxy-from-env: "npm:^1.1.0"
checksum: 026f9a2fef869d7883ed893f982dd3336fc66886c9a041b655b20e6f4b16cbc21975575454b6155f018663cc7ebceb8d0a19e65eaa62087595220d738faac830
languageName: node
linkType: hard

"babel-jest@npm:^29.2.1":
version: 29.2.1
resolution: "babel-jest@npm:29.2.1"
Expand Down Expand Up @@ -6403,7 +6414,7 @@ __metadata:
"@types/luxon": "npm:3.0.2"
"@types/node": "npm:18.11.3"
"@types/react": "npm:18.0.21"
axios: "npm:1.1.3"
axios: "patch:axios@npm%3A1.1.3#~/.yarn/patches/axios-npm-1.1.3-4b63965ac1.patch"
axios-retry: "npm:3.3.1"
chalk: "npm:5.1.2"
csv-parse: "npm:5.3.1"
Expand Down

0 comments on commit 6c3288a

Please sign in to comment.